2024-01-10 17:05:12 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2023-09-14 17:40:54 +00:00
|
|
|
syntax = "proto3";
|
|
|
|
|
2023-09-22 16:51:15 +00:00
|
|
|
package hashicorp.consul.auth.v2beta1;
|
2023-09-14 17:40:54 +00:00
|
|
|
|
2023-09-21 21:18:47 +00:00
|
|
|
import "pbresource/annotations.proto";
|
|
|
|
|
2023-09-14 17:40:54 +00:00
|
|
|
message TrafficPermissions {
|
2023-09-21 21:18:47 +00:00
|
|
|
option (hashicorp.consul.resource.spec) = {scope: SCOPE_NAMESPACE};
|
|
|
|
|
2023-10-13 14:55:58 +00:00
|
|
|
// Destination is a configuration of the destination proxies
|
2023-09-14 17:40:54 +00:00
|
|
|
// where these traffic permissions should apply.
|
|
|
|
Destination destination = 1;
|
|
|
|
|
|
|
|
// Action can be either allow or deny for the entire object. It will default to allow.
|
|
|
|
//
|
2023-10-13 14:55:58 +00:00
|
|
|
// If action is allow, we will allow the connection if one of the rules in Rules matches, in other words, we will deny
|
2023-09-14 17:40:54 +00:00
|
|
|
// all requests except for the ones that match Rules. If Consul is in default allow mode, then allow
|
|
|
|
// actions have no effect without a deny permission as everything is allowed by default.
|
|
|
|
//
|
2023-10-13 14:55:58 +00:00
|
|
|
// If action is deny, we will deny the connection if one of the rules in Rules match, in other words,
|
2023-09-14 17:40:54 +00:00
|
|
|
// we will allow all requests except for the ones that match Rules. If Consul is default deny mode,
|
|
|
|
// then deny permissions have no effect without an allow permission as everything is denied by default.
|
|
|
|
//
|
|
|
|
// Action unspecified is reserved for compatibility with the addition of future actions.
|
|
|
|
Action action = 2;
|
|
|
|
|
2023-10-13 14:55:58 +00:00
|
|
|
// Permissions is a list of permissions to match on. They are applied using OR semantics.
|
2023-09-14 17:40:54 +00:00
|
|
|
repeated Permission permissions = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
message NamespaceTrafficPermissions {
|
2023-09-21 21:18:47 +00:00
|
|
|
option (hashicorp.consul.resource.spec) = {scope: SCOPE_NAMESPACE};
|
|
|
|
|
2023-09-14 17:40:54 +00:00
|
|
|
Action action = 1;
|
|
|
|
repeated Permission permissions = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
message PartitionTrafficPermissions {
|
2023-09-21 21:18:47 +00:00
|
|
|
option (hashicorp.consul.resource.spec) = {scope: SCOPE_PARTITION};
|
|
|
|
|
2023-09-14 17:40:54 +00:00
|
|
|
Action action = 1;
|
|
|
|
repeated Permission permissions = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Destination contains the name or name-prefix of the WorkloadIdentity.
|
2023-10-13 14:55:58 +00:00
|
|
|
// The WorkloadIdentity resource must be in the same tenancy as the TrafficPermissions resource.
|
2023-09-14 17:40:54 +00:00
|
|
|
message Destination {
|
|
|
|
string identity_name = 1;
|
|
|
|
}
|
|
|
|
|
2023-10-13 14:55:58 +00:00
|
|
|
// +kubebuilder:validation:Enum=ACTION_ALLOW;ACTION_DENY;ACTION_UNKNOWN
|
|
|
|
// +kubebuilder:validation:Type=string
|
2023-09-14 17:40:54 +00:00
|
|
|
enum Action {
|
|
|
|
ACTION_UNSPECIFIED = 0;
|
|
|
|
ACTION_DENY = 1;
|
|
|
|
ACTION_ALLOW = 2;
|
|
|
|
}
|
|
|
|
|
2023-10-13 14:55:58 +00:00
|
|
|
// Permissions is a list of permissions to match on.
|
2023-09-14 17:40:54 +00:00
|
|
|
message Permission {
|
2023-10-13 14:55:58 +00:00
|
|
|
// Sources is a list of sources in this traffic permission.
|
2023-09-14 17:40:54 +00:00
|
|
|
repeated Source sources = 1;
|
2023-10-13 14:55:58 +00:00
|
|
|
// DestinationRules is a list of rules to apply for matching sources in this Permission.
|
2023-09-14 17:40:54 +00:00
|
|
|
// These rules are specific to the request or connection that is going to the destination(s)
|
|
|
|
// selected by the TrafficPermissions resource.
|
|
|
|
repeated DestinationRule destination_rules = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Source represents the source identity.
|
|
|
|
// To specify any of the wildcard sources, the specific fields need to be omitted.
|
|
|
|
// For example, for a wildcard namespace, identity_name should be omitted.
|
|
|
|
message Source {
|
|
|
|
string identity_name = 1;
|
|
|
|
string namespace = 2;
|
|
|
|
string partition = 3;
|
|
|
|
string peer = 4;
|
|
|
|
string sameness_group = 5;
|
|
|
|
|
2023-10-13 14:55:58 +00:00
|
|
|
// Exclude is a list of sources to exclude from this source.
|
2023-09-14 17:40:54 +00:00
|
|
|
repeated ExcludeSource exclude = 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExcludeSource is almost the same as source but it prevents the addition of
|
2023-10-13 14:55:58 +00:00
|
|
|
// matching sources.
|
2023-09-14 17:40:54 +00:00
|
|
|
message ExcludeSource {
|
|
|
|
string identity_name = 1;
|
|
|
|
string namespace = 2;
|
|
|
|
string partition = 3;
|
|
|
|
string peer = 4;
|
|
|
|
string sameness_group = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
// DestinationRule contains rules rules to apply to the incoming connection.
|
|
|
|
message DestinationRule {
|
|
|
|
string path_exact = 1;
|
|
|
|
string path_prefix = 2;
|
|
|
|
string path_regex = 3;
|
2023-10-13 14:55:58 +00:00
|
|
|
// Methods is the list of HTTP methods. If no methods are specified,
|
2023-09-14 17:40:54 +00:00
|
|
|
// this rule will apply to all methods.
|
|
|
|
repeated string methods = 4;
|
2024-01-24 02:07:58 +00:00
|
|
|
repeated DestinationRuleHeader headers = 5;
|
2023-09-14 17:40:54 +00:00
|
|
|
repeated string port_names = 6;
|
2023-10-13 14:55:58 +00:00
|
|
|
// Exclude contains a list of rules to exclude when evaluating rules for the incoming connection.
|
2023-09-14 17:40:54 +00:00
|
|
|
repeated ExcludePermissionRule exclude = 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
message ExcludePermissionRule {
|
|
|
|
string path_exact = 1;
|
|
|
|
string path_prefix = 2;
|
|
|
|
string path_regex = 3;
|
2023-10-13 14:55:58 +00:00
|
|
|
// Methods is the list of HTTP methods.
|
2023-09-14 17:40:54 +00:00
|
|
|
repeated string methods = 4;
|
|
|
|
|
2024-01-24 02:07:58 +00:00
|
|
|
repeated DestinationRuleHeader headers = 5;
|
2023-09-14 17:40:54 +00:00
|
|
|
|
2023-10-13 14:55:58 +00:00
|
|
|
// PortNames is a list of workload ports to apply this rule to. The ports specified here
|
2023-09-14 17:40:54 +00:00
|
|
|
// must be the ports used in the connection.
|
|
|
|
repeated string port_names = 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
message DestinationRuleHeader {
|
|
|
|
string name = 1;
|
|
|
|
bool present = 2;
|
|
|
|
string exact = 3;
|
|
|
|
string prefix = 4;
|
|
|
|
string suffix = 5;
|
|
|
|
string regex = 6;
|
|
|
|
bool invert = 7;
|
|
|
|
}
|