authorization_policy.proto 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. // Copyright 2022 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.cloud.networksecurity.v1;
  16. import "google/api/field_behavior.proto";
  17. import "google/api/resource.proto";
  18. import "google/protobuf/field_mask.proto";
  19. import "google/protobuf/timestamp.proto";
  20. option csharp_namespace = "Google.Cloud.NetworkSecurity.V1";
  21. option go_package = "google.golang.org/genproto/googleapis/cloud/networksecurity/v1;networksecurity";
  22. option java_multiple_files = true;
  23. option java_outer_classname = "AuthorizationPolicyProto";
  24. option java_package = "com.google.cloud.networksecurity.v1";
  25. option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1";
  26. option ruby_package = "Google::Cloud::NetworkSecurity::V1";
  27. // AuthorizationPolicy is a resource that specifies how a server
  28. // should authorize incoming connections. This resource in itself does
  29. // not change the configuration unless it's attached to a target https
  30. // proxy or endpoint config selector resource.
  31. message AuthorizationPolicy {
  32. option (google.api.resource) = {
  33. type: "networksecurity.googleapis.com/AuthorizationPolicy"
  34. pattern: "projects/{project}/locations/{location}/authorizationPolicies/{authorization_policy}"
  35. };
  36. // Specification of rules.
  37. message Rule {
  38. // Specification of traffic source attributes.
  39. message Source {
  40. // Optional. List of peer identities to match for authorization. At least one
  41. // principal should match. Each peer can be an exact match, or a prefix
  42. // match (example, "namespace/*") or a suffix match (example,
  43. // "*/service-account") or a presence match "*". Authorization based on
  44. // the principal name without certificate validation (configured by
  45. // ServerTlsPolicy resource) is considered insecure.
  46. repeated string principals = 1 [(google.api.field_behavior) = OPTIONAL];
  47. // Optional. List of CIDR ranges to match based on source IP address. At least one
  48. // IP block should match. Single IP (e.g., "1.2.3.4") and CIDR (e.g.,
  49. // "1.2.3.0/24") are supported. Authorization based on source IP alone
  50. // should be avoided. The IP addresses of any load balancers or proxies
  51. // should be considered untrusted.
  52. repeated string ip_blocks = 2 [(google.api.field_behavior) = OPTIONAL];
  53. }
  54. // Specification of traffic destination attributes.
  55. message Destination {
  56. // Specification of HTTP header match attributes.
  57. message HttpHeaderMatch {
  58. oneof type {
  59. // Required. The value of the header must match the regular expression
  60. // specified in regexMatch. For regular expression grammar,
  61. // please see: en.cppreference.com/w/cpp/regex/ecmascript
  62. // For matching against a port specified in the HTTP
  63. // request, use a headerMatch with headerName set to Host
  64. // and a regular expression that satisfies the RFC2616 Host
  65. // header's port specifier.
  66. string regex_match = 2 [(google.api.field_behavior) = REQUIRED];
  67. }
  68. // Required. The name of the HTTP header to match. For matching
  69. // against the HTTP request's authority, use a headerMatch
  70. // with the header name ":authority". For matching a
  71. // request's method, use the headerName ":method".
  72. string header_name = 1 [(google.api.field_behavior) = REQUIRED];
  73. }
  74. // Required. List of host names to match. Matched against the ":authority" header in
  75. // http requests. At least one host should match. Each host can be an
  76. // exact match, or a prefix match (example "mydomain.*") or a suffix
  77. // match (example "*.myorg.com") or a presence (any) match "*".
  78. repeated string hosts = 1 [(google.api.field_behavior) = REQUIRED];
  79. // Required. List of destination ports to match. At least one port should match.
  80. repeated uint32 ports = 2 [(google.api.field_behavior) = REQUIRED];
  81. // Optional. A list of HTTP methods to match. At least one method should
  82. // match. Should not be set for gRPC services.
  83. repeated string methods = 4 [(google.api.field_behavior) = OPTIONAL];
  84. // Optional. Match against key:value pair in http header. Provides a flexible match
  85. // based on HTTP headers, for potentially advanced use cases. At least one
  86. // header should match. Avoid using header matches to make authorization
  87. // decisions unless there is a strong guarantee that requests arrive
  88. // through a trusted client or proxy.
  89. HttpHeaderMatch http_header_match = 5 [(google.api.field_behavior) = OPTIONAL];
  90. }
  91. // Optional. List of attributes for the traffic source. All of the sources must match.
  92. // A source is a match if both principals and ip_blocks match. If not set,
  93. // the action specified in the 'action' field will be applied without any
  94. // rule checks for the source.
  95. repeated Source sources = 1 [(google.api.field_behavior) = OPTIONAL];
  96. // Optional. List of attributes for the traffic destination. All of the destinations
  97. // must match. A destination is a match if a request matches all the
  98. // specified hosts, ports, methods and headers. If not set, the
  99. // action specified in the 'action' field will be applied without any rule
  100. // checks for the destination.
  101. repeated Destination destinations = 2 [(google.api.field_behavior) = OPTIONAL];
  102. }
  103. // Possible values that define what action to take.
  104. enum Action {
  105. // Default value.
  106. ACTION_UNSPECIFIED = 0;
  107. // Grant access.
  108. ALLOW = 1;
  109. // Deny access.
  110. // Deny rules should be avoided unless they are used to provide a default
  111. // "deny all" fallback.
  112. DENY = 2;
  113. }
  114. // Required. Name of the AuthorizationPolicy resource. It matches pattern
  115. // `projects/{project}/locations/{location}/authorizationPolicies/<authorization_policy>`.
  116. string name = 1 [(google.api.field_behavior) = REQUIRED];
  117. // Optional. Free-text description of the resource.
  118. string description = 2 [(google.api.field_behavior) = OPTIONAL];
  119. // Output only. The timestamp when the resource was created.
  120. google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
  121. // Output only. The timestamp when the resource was updated.
  122. google.protobuf.Timestamp update_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
  123. // Optional. Set of label tags associated with the AuthorizationPolicy resource.
  124. map<string, string> labels = 5 [(google.api.field_behavior) = OPTIONAL];
  125. // Required. The action to take when a rule match is found. Possible values
  126. // are "ALLOW" or "DENY".
  127. Action action = 6 [(google.api.field_behavior) = REQUIRED];
  128. // Optional. List of rules to match. Note that at least one of the rules must match in
  129. // order for the action specified in the 'action' field to be taken. A rule is
  130. // a match if there is a matching source and destination. If left blank, the
  131. // action specified in the `action` field will be applied on every request.
  132. repeated Rule rules = 7 [(google.api.field_behavior) = OPTIONAL];
  133. }
  134. // Request used with the ListAuthorizationPolicies method.
  135. message ListAuthorizationPoliciesRequest {
  136. // Required. The project and location from which the AuthorizationPolicies
  137. // should be listed, specified in the format
  138. // `projects/{project}/locations/{location}`.
  139. string parent = 1 [
  140. (google.api.field_behavior) = REQUIRED,
  141. (google.api.resource_reference) = {
  142. type: "locations.googleapis.com/Location"
  143. }
  144. ];
  145. // Maximum number of AuthorizationPolicies to return per call.
  146. int32 page_size = 2;
  147. // The value returned by the last
  148. // `ListAuthorizationPoliciesResponse` Indicates that this is a
  149. // continuation of a prior `ListAuthorizationPolicies` call, and
  150. // that the system should return the next page of data.
  151. string page_token = 3;
  152. }
  153. // Response returned by the ListAuthorizationPolicies method.
  154. message ListAuthorizationPoliciesResponse {
  155. // List of AuthorizationPolicies resources.
  156. repeated AuthorizationPolicy authorization_policies = 1;
  157. // If there might be more results than those appearing in this response, then
  158. // `next_page_token` is included. To get the next set of results, call this
  159. // method again using the value of `next_page_token` as `page_token`.
  160. string next_page_token = 2;
  161. }
  162. // Request used by the GetAuthorizationPolicy method.
  163. message GetAuthorizationPolicyRequest {
  164. // Required. A name of the AuthorizationPolicy to get. Must be in the format
  165. // `projects/{project}/locations/{location}/authorizationPolicies/*`.
  166. string name = 1 [
  167. (google.api.field_behavior) = REQUIRED,
  168. (google.api.resource_reference) = {
  169. type: "networksecurity.googleapis.com/AuthorizationPolicy"
  170. }
  171. ];
  172. }
  173. // Request used by the CreateAuthorizationPolicy method.
  174. message CreateAuthorizationPolicyRequest {
  175. // Required. The parent resource of the AuthorizationPolicy. Must be in the
  176. // format `projects/{project}/locations/{location}`.
  177. string parent = 1 [
  178. (google.api.field_behavior) = REQUIRED,
  179. (google.api.resource_reference) = {
  180. child_type: "networksecurity.googleapis.com/AuthorizationPolicy"
  181. }
  182. ];
  183. // Required. Short name of the AuthorizationPolicy resource to be created.
  184. // This value should be 1-63 characters long, containing only
  185. // letters, numbers, hyphens, and underscores, and should not start
  186. // with a number. E.g. "authz_policy".
  187. string authorization_policy_id = 2 [(google.api.field_behavior) = REQUIRED];
  188. // Required. AuthorizationPolicy resource to be created.
  189. AuthorizationPolicy authorization_policy = 3 [(google.api.field_behavior) = REQUIRED];
  190. }
  191. // Request used by the UpdateAuthorizationPolicy method.
  192. message UpdateAuthorizationPolicyRequest {
  193. // Optional. Field mask is used to specify the fields to be overwritten in the
  194. // AuthorizationPolicy resource by the update.
  195. // The fields specified in the update_mask are relative to the resource, not
  196. // the full request. A field will be overwritten if it is in the mask. If the
  197. // user does not provide a mask then all fields will be overwritten.
  198. google.protobuf.FieldMask update_mask = 1 [(google.api.field_behavior) = OPTIONAL];
  199. // Required. Updated AuthorizationPolicy resource.
  200. AuthorizationPolicy authorization_policy = 2 [(google.api.field_behavior) = REQUIRED];
  201. }
  202. // Request used by the DeleteAuthorizationPolicy method.
  203. message DeleteAuthorizationPolicyRequest {
  204. // Required. A name of the AuthorizationPolicy to delete. Must be in the format
  205. // `projects/{project}/locations/{location}/authorizationPolicies/*`.
  206. string name = 1 [
  207. (google.api.field_behavior) = REQUIRED,
  208. (google.api.resource_reference) = {
  209. type: "networksecurity.googleapis.com/AuthorizationPolicy"
  210. }
  211. ];
  212. }