rbac.proto 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. syntax = "proto3";
  2. package envoy.config.rbac.v2;
  3. import "envoy/api/v2/core/address.proto";
  4. import "envoy/api/v2/route/route_components.proto";
  5. import "envoy/type/matcher/metadata.proto";
  6. import "envoy/type/matcher/path.proto";
  7. import "envoy/type/matcher/string.proto";
  8. import "google/api/expr/v1alpha1/syntax.proto";
  9. import "udpa/annotations/status.proto";
  10. import "validate/validate.proto";
  11. option java_package = "io.envoyproxy.envoy.config.rbac.v2";
  12. option java_outer_classname = "RbacProto";
  13. option java_multiple_files = true;
  14. option go_package = "github.com/envoyproxy/go-control-plane/envoy/config/rbac/v2;rbacv2";
  15. option (udpa.annotations.file_status).package_version_status = FROZEN;
  16. // [#protodoc-title: Role Based Access Control (RBAC)]
  17. // Role Based Access Control (RBAC) provides service-level and method-level access control for a
  18. // service. RBAC policies are additive. The policies are examined in order. A request is allowed
  19. // once a matching policy is found (suppose the `action` is ALLOW).
  20. //
  21. // Here is an example of RBAC configuration. It has two policies:
  22. //
  23. // * Service account "cluster.local/ns/default/sa/admin" has full access to the service, and so
  24. // does "cluster.local/ns/default/sa/superuser".
  25. //
  26. // * Any user can read ("GET") the service at paths with prefix "/products", so long as the
  27. // destination port is either 80 or 443.
  28. //
  29. // .. code-block:: yaml
  30. //
  31. // action: ALLOW
  32. // policies:
  33. // "service-admin":
  34. // permissions:
  35. // - any: true
  36. // principals:
  37. // - authenticated:
  38. // principal_name:
  39. // exact: "cluster.local/ns/default/sa/admin"
  40. // - authenticated:
  41. // principal_name:
  42. // exact: "cluster.local/ns/default/sa/superuser"
  43. // "product-viewer":
  44. // permissions:
  45. // - and_rules:
  46. // rules:
  47. // - header: { name: ":method", exact_match: "GET" }
  48. // - url_path:
  49. // path: { prefix: "/products" }
  50. // - or_rules:
  51. // rules:
  52. // - destination_port: 80
  53. // - destination_port: 443
  54. // principals:
  55. // - any: true
  56. //
  57. message RBAC {
  58. // Should we do safe-list or block-list style access control?
  59. enum Action {
  60. // The policies grant access to principals. The rest is denied. This is safe-list style
  61. // access control. This is the default type.
  62. ALLOW = 0;
  63. // The policies deny access to principals. The rest is allowed. This is block-list style
  64. // access control.
  65. DENY = 1;
  66. }
  67. // The action to take if a policy matches. The request is allowed if and only if:
  68. //
  69. // * `action` is "ALLOWED" and at least one policy matches
  70. // * `action` is "DENY" and none of the policies match
  71. Action action = 1;
  72. // Maps from policy name to policy. A match occurs when at least one policy matches the request.
  73. map<string, Policy> policies = 2;
  74. }
  75. // Policy specifies a role and the principals that are assigned/denied the role. A policy matches if
  76. // and only if at least one of its permissions match the action taking place AND at least one of its
  77. // principals match the downstream AND the condition is true if specified.
  78. message Policy {
  79. // Required. The set of permissions that define a role. Each permission is matched with OR
  80. // semantics. To match all actions for this policy, a single Permission with the `any` field set
  81. // to true should be used.
  82. repeated Permission permissions = 1 [(validate.rules).repeated = {min_items: 1}];
  83. // Required. The set of principals that are assigned/denied the role based on “action”. Each
  84. // principal is matched with OR semantics. To match all downstreams for this policy, a single
  85. // Principal with the `any` field set to true should be used.
  86. repeated Principal principals = 2 [(validate.rules).repeated = {min_items: 1}];
  87. // An optional symbolic expression specifying an access control
  88. // :ref:`condition <arch_overview_condition>`. The condition is combined
  89. // with the permissions and the principals as a clause with AND semantics.
  90. google.api.expr.v1alpha1.Expr condition = 3;
  91. }
  92. // Permission defines an action (or actions) that a principal can take.
  93. // [#next-free-field: 11]
  94. message Permission {
  95. // Used in the `and_rules` and `or_rules` fields in the `rule` oneof. Depending on the context,
  96. // each are applied with the associated behavior.
  97. message Set {
  98. repeated Permission rules = 1 [(validate.rules).repeated = {min_items: 1}];
  99. }
  100. oneof rule {
  101. option (validate.required) = true;
  102. // A set of rules that all must match in order to define the action.
  103. Set and_rules = 1;
  104. // A set of rules where at least one must match in order to define the action.
  105. Set or_rules = 2;
  106. // When any is set, it matches any action.
  107. bool any = 3 [(validate.rules).bool = {const: true}];
  108. // A header (or pseudo-header such as :path or :method) on the incoming HTTP request. Only
  109. // available for HTTP request.
  110. // Note: the pseudo-header :path includes the query and fragment string. Use the `url_path`
  111. // field if you want to match the URL path without the query and fragment string.
  112. api.v2.route.HeaderMatcher header = 4;
  113. // A URL path on the incoming HTTP request. Only available for HTTP.
  114. type.matcher.PathMatcher url_path = 10;
  115. // A CIDR block that describes the destination IP.
  116. api.v2.core.CidrRange destination_ip = 5;
  117. // A port number that describes the destination port connecting to.
  118. uint32 destination_port = 6 [(validate.rules).uint32 = {lte: 65535}];
  119. // Metadata that describes additional information about the action.
  120. type.matcher.MetadataMatcher metadata = 7;
  121. // Negates matching the provided permission. For instance, if the value of `not_rule` would
  122. // match, this permission would not match. Conversely, if the value of `not_rule` would not
  123. // match, this permission would match.
  124. Permission not_rule = 8;
  125. // The request server from the client's connection request. This is
  126. // typically TLS SNI.
  127. //
  128. // .. attention::
  129. //
  130. // The behavior of this field may be affected by how Envoy is configured
  131. // as explained below.
  132. //
  133. // * If the :ref:`TLS Inspector <config_listener_filters_tls_inspector>`
  134. // filter is not added, and if a `FilterChainMatch` is not defined for
  135. // the :ref:`server name <envoy_api_field_listener.FilterChainMatch.server_names>`,
  136. // a TLS connection's requested SNI server name will be treated as if it
  137. // wasn't present.
  138. //
  139. // * A :ref:`listener filter <arch_overview_listener_filters>` may
  140. // overwrite a connection's requested server name within Envoy.
  141. //
  142. // Please refer to :ref:`this FAQ entry <faq_how_to_setup_sni>` to learn to
  143. // setup SNI.
  144. type.matcher.StringMatcher requested_server_name = 9;
  145. }
  146. }
  147. // Principal defines an identity or a group of identities for a downstream subject.
  148. // [#next-free-field: 12]
  149. message Principal {
  150. // Used in the `and_ids` and `or_ids` fields in the `identifier` oneof. Depending on the context,
  151. // each are applied with the associated behavior.
  152. message Set {
  153. repeated Principal ids = 1 [(validate.rules).repeated = {min_items: 1}];
  154. }
  155. // Authentication attributes for a downstream.
  156. message Authenticated {
  157. reserved 1;
  158. // The name of the principal. If set, The URI SAN or DNS SAN in that order is used from the
  159. // certificate, otherwise the subject field is used. If unset, it applies to any user that is
  160. // authenticated.
  161. type.matcher.StringMatcher principal_name = 2;
  162. }
  163. oneof identifier {
  164. option (validate.required) = true;
  165. // A set of identifiers that all must match in order to define the downstream.
  166. Set and_ids = 1;
  167. // A set of identifiers at least one must match in order to define the downstream.
  168. Set or_ids = 2;
  169. // When any is set, it matches any downstream.
  170. bool any = 3 [(validate.rules).bool = {const: true}];
  171. // Authenticated attributes that identify the downstream.
  172. Authenticated authenticated = 4;
  173. // A CIDR block that describes the downstream IP.
  174. // This address will honor proxy protocol, but will not honor XFF.
  175. api.v2.core.CidrRange source_ip = 5 [deprecated = true];
  176. // A CIDR block that describes the downstream remote/origin address.
  177. // Note: This is always the physical peer even if the
  178. // :ref:`remote_ip <envoy_api_field_config.rbac.v2.Principal.remote_ip>` is inferred
  179. // from for example the x-forwarder-for header, proxy protocol, etc.
  180. api.v2.core.CidrRange direct_remote_ip = 10;
  181. // A CIDR block that describes the downstream remote/origin address.
  182. // Note: This may not be the physical peer and could be different from the
  183. // :ref:`direct_remote_ip <envoy_api_field_config.rbac.v2.Principal.direct_remote_ip>`.
  184. // E.g, if the remote ip is inferred from for example the x-forwarder-for header,
  185. // proxy protocol, etc.
  186. api.v2.core.CidrRange remote_ip = 11;
  187. // A header (or pseudo-header such as :path or :method) on the incoming HTTP request. Only
  188. // available for HTTP request.
  189. // Note: the pseudo-header :path includes the query and fragment string. Use the `url_path`
  190. // field if you want to match the URL path without the query and fragment string.
  191. api.v2.route.HeaderMatcher header = 6;
  192. // A URL path on the incoming HTTP request. Only available for HTTP.
  193. type.matcher.PathMatcher url_path = 9;
  194. // Metadata that describes additional information about the principal.
  195. type.matcher.MetadataMatcher metadata = 7;
  196. // Negates matching the provided principal. For instance, if the value of `not_id` would match,
  197. // this principal would not match. Conversely, if the value of `not_id` would not match, this
  198. // principal would match.
  199. Principal not_id = 8;
  200. }
  201. }