policy.proto 15 KB

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