policy.proto 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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.iam.v1;
  16. import "google/type/expr.proto";
  17. option cc_enable_arenas = true;
  18. option csharp_namespace = "Google.Cloud.Iam.V1";
  19. option go_package = "google.golang.org/genproto/googleapis/iam/v1;iam";
  20. option java_multiple_files = true;
  21. option java_outer_classname = "PolicyProto";
  22. option java_package = "com.google.iam.v1";
  23. option php_namespace = "Google\\Cloud\\Iam\\V1";
  24. // An Identity and Access Management (IAM) policy, which specifies access
  25. // controls for Google Cloud resources.
  26. //
  27. //
  28. // A `Policy` is a collection of `bindings`. A `binding` binds one or more
  29. // `members`, or principals, to a single `role`. Principals can be user
  30. // accounts, service accounts, Google groups, and domains (such as G Suite). A
  31. // `role` is a named list of permissions; each `role` can be an IAM predefined
  32. // role or a user-created custom role.
  33. //
  34. // For some types of Google Cloud resources, a `binding` can also specify a
  35. // `condition`, which is a logical expression that allows access to a resource
  36. // only if the expression evaluates to `true`. A condition can add constraints
  37. // based on attributes of the request, the resource, or both. To learn which
  38. // resources support conditions in their IAM policies, see the
  39. // [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
  40. //
  41. // **JSON example:**
  42. //
  43. // {
  44. // "bindings": [
  45. // {
  46. // "role": "roles/resourcemanager.organizationAdmin",
  47. // "members": [
  48. // "user:mike@example.com",
  49. // "group:admins@example.com",
  50. // "domain:google.com",
  51. // "serviceAccount:my-project-id@appspot.gserviceaccount.com"
  52. // ]
  53. // },
  54. // {
  55. // "role": "roles/resourcemanager.organizationViewer",
  56. // "members": [
  57. // "user:eve@example.com"
  58. // ],
  59. // "condition": {
  60. // "title": "expirable access",
  61. // "description": "Does not grant access after Sep 2020",
  62. // "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')",
  63. // }
  64. // }
  65. // ],
  66. // "etag": "BwWWja0YfJA=",
  67. // "version": 3
  68. // }
  69. //
  70. // **YAML example:**
  71. //
  72. // bindings:
  73. // - members:
  74. // - user:mike@example.com
  75. // - group:admins@example.com
  76. // - domain:google.com
  77. // - serviceAccount:my-project-id@appspot.gserviceaccount.com
  78. // role: roles/resourcemanager.organizationAdmin
  79. // - members:
  80. // - user:eve@example.com
  81. // role: roles/resourcemanager.organizationViewer
  82. // condition:
  83. // title: expirable access
  84. // description: Does not grant access after Sep 2020
  85. // expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
  86. // etag: BwWWja0YfJA=
  87. // version: 3
  88. //
  89. // For a description of IAM and its features, see the
  90. // [IAM documentation](https://cloud.google.com/iam/docs/).
  91. message Policy {
  92. // Specifies the format of the policy.
  93. //
  94. // Valid values are `0`, `1`, and `3`. Requests that specify an invalid value
  95. // are rejected.
  96. //
  97. // Any operation that affects conditional role bindings must specify version
  98. // `3`. This requirement applies to the following operations:
  99. //
  100. // * Getting a policy that includes a conditional role binding
  101. // * Adding a conditional role binding to a policy
  102. // * Changing a conditional role binding in a policy
  103. // * Removing any role binding, with or without a condition, from a policy
  104. // that includes conditions
  105. //
  106. // **Important:** If you use IAM Conditions, you must include the `etag` field
  107. // whenever you call `setIamPolicy`. If you omit this field, then IAM allows
  108. // you to overwrite a version `3` policy with a version `1` policy, and all of
  109. // the conditions in the version `3` policy are lost.
  110. //
  111. // If a policy does not include any conditions, operations on that policy may
  112. // specify any valid version or leave the field unset.
  113. //
  114. // To learn which resources support conditions in their IAM policies, see the
  115. // [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
  116. int32 version = 1;
  117. // Associates a list of `members`, or principals, with a `role`. Optionally,
  118. // may specify a `condition` that determines how and when the `bindings` are
  119. // applied. Each of the `bindings` must contain at least one principal.
  120. //
  121. // The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250
  122. // of these principals can be Google groups. Each occurrence of a principal
  123. // counts towards these limits. For example, if the `bindings` grant 50
  124. // different roles to `user:alice@example.com`, and not to any other
  125. // principal, then you can add another 1,450 principals to the `bindings` in
  126. // the `Policy`.
  127. repeated Binding bindings = 4;
  128. // Specifies cloud audit logging configuration for this policy.
  129. repeated AuditConfig audit_configs = 6;
  130. // `etag` is used for optimistic concurrency control as a way to help
  131. // prevent simultaneous updates of a policy from overwriting each other.
  132. // It is strongly suggested that systems make use of the `etag` in the
  133. // read-modify-write cycle to perform policy updates in order to avoid race
  134. // conditions: An `etag` is returned in the response to `getIamPolicy`, and
  135. // systems are expected to put that etag in the request to `setIamPolicy` to
  136. // ensure that their change will be applied to the same version of the policy.
  137. //
  138. // **Important:** If you use IAM Conditions, you must include the `etag` field
  139. // whenever you call `setIamPolicy`. If you omit this field, then IAM allows
  140. // you to overwrite a version `3` policy with a version `1` policy, and all of
  141. // the conditions in the version `3` policy are lost.
  142. bytes etag = 3;
  143. }
  144. // Associates `members`, or principals, with a `role`.
  145. message Binding {
  146. // Role that is assigned to the list of `members`, or principals.
  147. // For example, `roles/viewer`, `roles/editor`, or `roles/owner`.
  148. string role = 1;
  149. // Specifies the principals requesting access for a Cloud Platform resource.
  150. // `members` can have the following values:
  151. //
  152. // * `allUsers`: A special identifier that represents anyone who is
  153. // on the internet; with or without a Google account.
  154. //
  155. // * `allAuthenticatedUsers`: A special identifier that represents anyone
  156. // who is authenticated with a Google account or a service account.
  157. //
  158. // * `user:{emailid}`: An email address that represents a specific Google
  159. // account. For example, `alice@example.com` .
  160. //
  161. //
  162. // * `serviceAccount:{emailid}`: An email address that represents a service
  163. // account. For example, `my-other-app@appspot.gserviceaccount.com`.
  164. //
  165. // * `group:{emailid}`: An email address that represents a Google group.
  166. // For example, `admins@example.com`.
  167. //
  168. // * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique
  169. // identifier) representing a user that has been recently deleted. For
  170. // example, `alice@example.com?uid=123456789012345678901`. If the user is
  171. // recovered, this value reverts to `user:{emailid}` and the recovered user
  172. // retains the role in the binding.
  173. //
  174. // * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus
  175. // unique identifier) representing a service account that has been recently
  176. // deleted. For example,
  177. // `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`.
  178. // If the service account is undeleted, this value reverts to
  179. // `serviceAccount:{emailid}` and the undeleted service account retains the
  180. // role in the binding.
  181. //
  182. // * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique
  183. // identifier) representing a Google group that has been recently
  184. // deleted. For example, `admins@example.com?uid=123456789012345678901`. If
  185. // the group is recovered, this value reverts to `group:{emailid}` and the
  186. // recovered group retains the role in the binding.
  187. //
  188. //
  189. // * `domain:{domain}`: The G Suite domain (primary) that represents all the
  190. // users of that domain. For example, `google.com` or `example.com`.
  191. //
  192. //
  193. repeated string members = 2;
  194. // The condition that is associated with this binding.
  195. //
  196. // If the condition evaluates to `true`, then this binding applies to the
  197. // current request.
  198. //
  199. // If the condition evaluates to `false`, then this binding does not apply to
  200. // the current request. However, a different role binding might grant the same
  201. // role to one or more of the principals in this binding.
  202. //
  203. // To learn which resources support conditions in their IAM policies, see the
  204. // [IAM
  205. // documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
  206. google.type.Expr condition = 3;
  207. }
  208. // Specifies the audit configuration for a service.
  209. // The configuration determines which permission types are logged, and what
  210. // identities, if any, are exempted from logging.
  211. // An AuditConfig must have one or more AuditLogConfigs.
  212. //
  213. // If there are AuditConfigs for both `allServices` and a specific service,
  214. // the union of the two AuditConfigs is used for that service: the log_types
  215. // specified in each AuditConfig are enabled, and the exempted_members in each
  216. // AuditLogConfig are exempted.
  217. //
  218. // Example Policy with multiple AuditConfigs:
  219. //
  220. // {
  221. // "audit_configs": [
  222. // {
  223. // "service": "allServices",
  224. // "audit_log_configs": [
  225. // {
  226. // "log_type": "DATA_READ",
  227. // "exempted_members": [
  228. // "user:jose@example.com"
  229. // ]
  230. // },
  231. // {
  232. // "log_type": "DATA_WRITE"
  233. // },
  234. // {
  235. // "log_type": "ADMIN_READ"
  236. // }
  237. // ]
  238. // },
  239. // {
  240. // "service": "sampleservice.googleapis.com",
  241. // "audit_log_configs": [
  242. // {
  243. // "log_type": "DATA_READ"
  244. // },
  245. // {
  246. // "log_type": "DATA_WRITE",
  247. // "exempted_members": [
  248. // "user:aliya@example.com"
  249. // ]
  250. // }
  251. // ]
  252. // }
  253. // ]
  254. // }
  255. //
  256. // For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ
  257. // logging. It also exempts jose@example.com from DATA_READ logging, and
  258. // aliya@example.com from DATA_WRITE logging.
  259. message AuditConfig {
  260. // Specifies a service that will be enabled for audit logging.
  261. // For example, `storage.googleapis.com`, `cloudsql.googleapis.com`.
  262. // `allServices` is a special value that covers all services.
  263. string service = 1;
  264. // The configuration for logging of each type of permission.
  265. repeated AuditLogConfig audit_log_configs = 3;
  266. }
  267. // Provides the configuration for logging a type of permissions.
  268. // Example:
  269. //
  270. // {
  271. // "audit_log_configs": [
  272. // {
  273. // "log_type": "DATA_READ",
  274. // "exempted_members": [
  275. // "user:jose@example.com"
  276. // ]
  277. // },
  278. // {
  279. // "log_type": "DATA_WRITE"
  280. // }
  281. // ]
  282. // }
  283. //
  284. // This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting
  285. // jose@example.com from DATA_READ logging.
  286. message AuditLogConfig {
  287. // The list of valid permission types for which logging can be configured.
  288. // Admin writes are always logged, and are not configurable.
  289. enum LogType {
  290. // Default case. Should never be this.
  291. LOG_TYPE_UNSPECIFIED = 0;
  292. // Admin reads. Example: CloudIAM getIamPolicy
  293. ADMIN_READ = 1;
  294. // Data writes. Example: CloudSQL Users create
  295. DATA_WRITE = 2;
  296. // Data reads. Example: CloudSQL Users list
  297. DATA_READ = 3;
  298. }
  299. // The log type that this config enables.
  300. LogType log_type = 1;
  301. // Specifies the identities that do not cause logging for this type of
  302. // permission.
  303. // Follows the same format of [Binding.members][google.iam.v1.Binding.members].
  304. repeated string exempted_members = 2;
  305. }
  306. // The difference delta between two policies.
  307. message PolicyDelta {
  308. // The delta for Bindings between two policies.
  309. repeated BindingDelta binding_deltas = 1;
  310. // The delta for AuditConfigs between two policies.
  311. repeated AuditConfigDelta audit_config_deltas = 2;
  312. }
  313. // One delta entry for Binding. Each individual change (only one member in each
  314. // entry) to a binding will be a separate entry.
  315. message BindingDelta {
  316. // The type of action performed on a Binding in a policy.
  317. enum Action {
  318. // Unspecified.
  319. ACTION_UNSPECIFIED = 0;
  320. // Addition of a Binding.
  321. ADD = 1;
  322. // Removal of a Binding.
  323. REMOVE = 2;
  324. }
  325. // The action that was performed on a Binding.
  326. // Required
  327. Action action = 1;
  328. // Role that is assigned to `members`.
  329. // For example, `roles/viewer`, `roles/editor`, or `roles/owner`.
  330. // Required
  331. string role = 2;
  332. // A single identity requesting access for a Cloud Platform resource.
  333. // Follows the same format of Binding.members.
  334. // Required
  335. string member = 3;
  336. // The condition that is associated with this binding.
  337. google.type.Expr condition = 4;
  338. }
  339. // One delta entry for AuditConfig. Each individual change (only one
  340. // exempted_member in each entry) to a AuditConfig will be a separate entry.
  341. message AuditConfigDelta {
  342. // The type of action performed on an audit configuration in a policy.
  343. enum Action {
  344. // Unspecified.
  345. ACTION_UNSPECIFIED = 0;
  346. // Addition of an audit configuration.
  347. ADD = 1;
  348. // Removal of an audit configuration.
  349. REMOVE = 2;
  350. }
  351. // The action that was performed on an audit configuration in a policy.
  352. // Required
  353. Action action = 1;
  354. // Specifies a service that was configured for Cloud Audit Logging.
  355. // For example, `storage.googleapis.com`, `cloudsql.googleapis.com`.
  356. // `allServices` is a special value that covers all services.
  357. // Required
  358. string service = 2;
  359. // A single identity that is exempted from "data access" audit
  360. // logging for the `service` specified above.
  361. // Follows the same format of Binding.members.
  362. string exempted_member = 3;
  363. // Specifies the log_type that was be enabled. ADMIN_ACTIVITY is always
  364. // enabled, and cannot be configured.
  365. // Required
  366. string log_type = 4;
  367. }