authorization_policy.proto 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. // Copyright 2021 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.v1beta1;
  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.V1Beta1";
  21. option go_package = "google.golang.org/genproto/googleapis/cloud/networksecurity/v1beta1;networksecurity";
  22. option java_multiple_files = true;
  23. option java_outer_classname = "AuthorizationPolicyProto";
  24. option java_package = "com.google.cloud.networksecurity.v1beta1";
  25. option php_namespace = "Google\\Cloud\\NetworkSecurity\\V1beta1";
  26. option ruby_package = "Google::Cloud::NetworkSecurity::V1beta1";
  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
  41. // one principal should match. Each peer can be an exact match, or a
  42. // prefix 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
  48. // least one IP block should match. Single IP (e.g., "1.2.3.4") and CIDR
  49. // (e.g., "1.2.3.0/24") are supported. Authorization based on source IP
  50. // alone should be avoided. The IP addresses of any load balancers or
  51. // proxies 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"
  75. // header in http requests. At least one host should match. Each host can
  76. // be an 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
  80. // match.
  81. repeated uint32 ports = 2 [(google.api.field_behavior) = REQUIRED];
  82. // Optional. A list of HTTP methods to match. At least one method should
  83. // match. Should not be set for gRPC services.
  84. repeated string methods = 4 [(google.api.field_behavior) = OPTIONAL];
  85. // Optional. Match against key:value pair in http header. Provides a
  86. // flexible match based on HTTP headers, for potentially advanced use
  87. // cases. At least one header should match. Avoid using header matches to
  88. // make authorization decisions unless there is a strong guarantee that
  89. // requests arrive through a trusted client or proxy.
  90. HttpHeaderMatch http_header_match = 5
  91. [(google.api.field_behavior) = OPTIONAL];
  92. }
  93. // Optional. List of attributes for the traffic source. All of the sources
  94. // must match. A source is a match if both principals and ip_blocks match.
  95. // If not set, the action specified in the 'action' field will be applied
  96. // without any rule checks for the source.
  97. repeated Source sources = 1 [(google.api.field_behavior) = OPTIONAL];
  98. // Optional. List of attributes for the traffic destination. All of the
  99. // destinations must match. A destination is a match if a request matches
  100. // all the specified hosts, ports, methods and headers. If not set, the
  101. // action specified in the 'action' field will be applied without any rule
  102. // checks for the destination.
  103. repeated Destination destinations = 2
  104. [(google.api.field_behavior) = OPTIONAL];
  105. }
  106. // Possible values that define what action to take.
  107. enum Action {
  108. // Default value.
  109. ACTION_UNSPECIFIED = 0;
  110. // Grant access.
  111. ALLOW = 1;
  112. // Deny access.
  113. // Deny rules should be avoided unless they are used to provide a default
  114. // "deny all" fallback.
  115. DENY = 2;
  116. }
  117. // Required. Name of the AuthorizationPolicy resource. It matches pattern
  118. // `projects/{project}/locations/{location}/authorizationPolicies/<authorization_policy>`.
  119. string name = 1 [(google.api.field_behavior) = REQUIRED];
  120. // Optional. Free-text description of the resource.
  121. string description = 2 [(google.api.field_behavior) = OPTIONAL];
  122. // Output only. The timestamp when the resource was created.
  123. google.protobuf.Timestamp create_time = 3
  124. [(google.api.field_behavior) = OUTPUT_ONLY];
  125. // Output only. The timestamp when the resource was updated.
  126. google.protobuf.Timestamp update_time = 4
  127. [(google.api.field_behavior) = OUTPUT_ONLY];
  128. // Optional. Set of label tags associated with the AuthorizationPolicy
  129. // resource.
  130. map<string, string> labels = 5 [(google.api.field_behavior) = OPTIONAL];
  131. // Required. The action to take when a rule match is found. Possible values
  132. // are "ALLOW" or "DENY".
  133. Action action = 6 [(google.api.field_behavior) = REQUIRED];
  134. // Optional. List of rules to match. Note that at least one of the rules must
  135. // match in order for the action specified in the 'action' field to be taken.
  136. // A rule is a match if there is a matching source and destination. If left
  137. // blank, the action specified in the `action` field will be applied on every
  138. // request.
  139. repeated Rule rules = 7 [(google.api.field_behavior) = OPTIONAL];
  140. }
  141. // Request used with the ListAuthorizationPolicies method.
  142. message ListAuthorizationPoliciesRequest {
  143. // Required. The project and location from which the AuthorizationPolicies
  144. // should be listed, specified in the format
  145. // `projects/{project}/locations/{location}`.
  146. string parent = 1 [
  147. (google.api.field_behavior) = REQUIRED,
  148. (google.api.resource_reference) = {
  149. type: "locations.googleapis.com/Location"
  150. }
  151. ];
  152. // Maximum number of AuthorizationPolicies to return per call.
  153. int32 page_size = 2;
  154. // The value returned by the last
  155. // `ListAuthorizationPoliciesResponse` Indicates that this is a
  156. // continuation of a prior `ListAuthorizationPolicies` call, and
  157. // that the system should return the next page of data.
  158. string page_token = 3;
  159. }
  160. // Response returned by the ListAuthorizationPolicies method.
  161. message ListAuthorizationPoliciesResponse {
  162. // List of AuthorizationPolicies resources.
  163. repeated AuthorizationPolicy authorization_policies = 1;
  164. // If there might be more results than those appearing in this response, then
  165. // `next_page_token` is included. To get the next set of results, call this
  166. // method again using the value of `next_page_token` as `page_token`.
  167. string next_page_token = 2;
  168. }
  169. // Request used by the GetAuthorizationPolicy method.
  170. message GetAuthorizationPolicyRequest {
  171. // Required. A name of the AuthorizationPolicy to get. Must be in the format
  172. // `projects/{project}/locations/{location}/authorizationPolicies/*`.
  173. string name = 1 [
  174. (google.api.field_behavior) = REQUIRED,
  175. (google.api.resource_reference) = {
  176. type: "networksecurity.googleapis.com/AuthorizationPolicy"
  177. }
  178. ];
  179. }
  180. // Request used by the CreateAuthorizationPolicy method.
  181. message CreateAuthorizationPolicyRequest {
  182. // Required. The parent resource of the AuthorizationPolicy. Must be in the
  183. // format `projects/{project}/locations/{location}`.
  184. string parent = 1 [
  185. (google.api.field_behavior) = REQUIRED,
  186. (google.api.resource_reference) = {
  187. child_type: "networksecurity.googleapis.com/AuthorizationPolicy"
  188. }
  189. ];
  190. // Required. Short name of the AuthorizationPolicy resource to be created.
  191. // This value should be 1-63 characters long, containing only
  192. // letters, numbers, hyphens, and underscores, and should not start
  193. // with a number. E.g. "authz_policy".
  194. string authorization_policy_id = 2 [(google.api.field_behavior) = REQUIRED];
  195. // Required. AuthorizationPolicy resource to be created.
  196. AuthorizationPolicy authorization_policy = 3
  197. [(google.api.field_behavior) = REQUIRED];
  198. }
  199. // Request used by the UpdateAuthorizationPolicy method.
  200. message UpdateAuthorizationPolicyRequest {
  201. // Optional. Field mask is used to specify the fields to be overwritten in the
  202. // AuthorizationPolicy resource by the update.
  203. // The fields specified in the update_mask are relative to the resource, not
  204. // the full request. A field will be overwritten if it is in the mask. If the
  205. // user does not provide a mask then all fields will be overwritten.
  206. google.protobuf.FieldMask update_mask = 1
  207. [(google.api.field_behavior) = OPTIONAL];
  208. // Required. Updated AuthorizationPolicy resource.
  209. AuthorizationPolicy authorization_policy = 2
  210. [(google.api.field_behavior) = REQUIRED];
  211. }
  212. // Request used by the DeleteAuthorizationPolicy method.
  213. message DeleteAuthorizationPolicyRequest {
  214. // Required. A name of the AuthorizationPolicy to delete. Must be in the
  215. // format `projects/{project}/locations/{location}/authorizationPolicies/*`.
  216. string name = 1 [
  217. (google.api.field_behavior) = REQUIRED,
  218. (google.api.resource_reference) = {
  219. type: "networksecurity.googleapis.com/AuthorizationPolicy"
  220. }
  221. ];
  222. }