rbac.proto 13 KB

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