Skip to content

Commit 8f79986

Browse files
authored
[AIP-4117] Adding documentation for configurable token lifetime (#938)
Adding documentation for configurable token lifetime for workload identity pools and ADC creation. Also reformatting header types so the table of contents is correct.
1 parent 09ea343 commit 8f79986

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

aip/auth/4117.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ $ gcloud iam workload-identity-pools create-cred-config \
7474
--output-file=$FILEPATH.json
7575
```
7676

77+
If you wish to configure the service account access token lifetime,
78+
an additional flag `--service-account-token-lifetime-seconds` should be added to the [`gcloud iam workload-identity-pools create-cred-config`](/sdk/gcloud/reference/iam/workload-identity-pools/create-cred-config) command (this example uses an AWS configuration, but the token lifetime can be configured for all workload identity federation providers):
79+
80+
```bash
81+
$ gcloud iam workload-identity-pools create-cred-config \
82+
projects/$PROJECT_NUMBER/locations/global/workloadIdentityPools/$POOL_ID/providers/$PROVIDER_ID \
83+
--service-account=$SERVICE_ACCOUNT_EMAIL \
84+
--aws \
85+
--service-account-token-lifetime-seconds=$TOKEN_LIFETIME \
86+
--output-file=$FILEPATH.json
87+
```
88+
89+
The service-account-token-lifetime-seconds flag is optional. If not provided, this defaults to one hour. The minimum allowed value is 600 (10 minutes) and the maximum allowed value is 43200 (12 hours). If a lifetime greater than one hour is required, the service account must be added as an allowed value in an Organization Policy that enforces the `constraints/iam.allowServiceAccountCredentialLifetimeExtension` constraint.
90+
7791
The external identities configuration file can be used with
7892
[Application Default Credentials][6]. In order to use external identities with
7993
Application Default Credentials, the full path to this file should be stored
@@ -119,7 +133,7 @@ scoped_credentials = credentials.with_scopes(
119133
['https://www.googleapis.com/auth/cloud-platform'])
120134
```
121135

122-
### Expected Behavior
136+
## Expected Behavior
123137

124138
The auth libraries should use the information in the JSON configuration file to
125139
retrieve the external credentials and exchange them for Google access tokens
@@ -136,6 +150,7 @@ All external account JSON files must share the following fields:
136150
| audience | Yes | This is the STS audience which contains the resource name for the workload identity pool and the provider identifier in that pool. |
137151
| subject_token_type | Yes | This is the STS subject token type based on the [OAuth 2.0 token exchange spec][7]. |
138152
| service_account_impersonation_url | No | This is the URL for the service account impersonation request. If this is not available, the STS returned access token should be directly used without impersonation. |
153+
| service_account_impersonation.* | No | This object defines additional service account impersonation options. Only one field is currently supported: “token_lifetime_seconds": This is the requested access token lifetime, e.g. `2800`. |
139154
| token_url | Yes | This is the STS token exchange endpoint. |
140155
| credential_source.* | Yes | This object defines the mechanism used to retrieve the external credential from the local environment so that it can be exchanged for a GCP access token via the STS endpoint. |
141156

@@ -176,8 +191,11 @@ types of external account credentials:
176191
`https://www.googleapis.com/auth/cloud-platform` or IAM scope
177192
`https://www.googleapis.com/auth/iam`) are required in the underlying
178193
access token.
194+
- The service account access token lifetime also needs to be provided for this endpoint. The value in
195+
**service_account_impersonation.token_lifetime_seconds** will be used if it
196+
was provided, otherwise it will default to 1 hour.
179197

180-
#### Determining the subject token in AWS
198+
### Determining the subject token in AWS
181199

182200
External account configuration JSON files should contain the following
183201
information in the `credential_source` object to facilitate retrieval of AWS
@@ -274,7 +292,7 @@ The auth libraries and applications **must** follow the steps below:
274292
```
275293
For the AWS token, STS requires a special header `x-goog-cloud-endpoint` to recognize that the token is for a specific workload identity provider.
276294

277-
#### Determining the subject token in Microsoft Azure and URL-sourced credentials
295+
### Determining the subject token in Microsoft Azure and URL-sourced credentials
278296

279297
External account configuration JSON files should contain the following
280298
information in the `credential_source` object to facilitate retrieval of Azure
@@ -347,7 +365,7 @@ The auth libraries and applications **must** follow the steps below:
347365
- Parse the file as JSON and then retrieve the external credential from
348366
the field name based on the value of **subject_token_field_name**.
349367

350-
#### Determining the subject token in file-sourced credentials
368+
### Determining the subject token in file-sourced credentials
351369

352370
External account configuration JSON files contain the following information
353371
in the `credential_source` object to facilitate retrieval of file-sourced
@@ -391,7 +409,7 @@ The auth libraries and applications **must** follow the steps below:
391409
the field name based on the value of **subject_token_field_name**.
392410

393411

394-
#### Determining the subject token in executable-sourced credentials
412+
### Determining the subject token in executable-sourced credentials
395413

396414
External account configuration JSON files contain the following information
397415
in the `credential_source` object to facilitate retrieval of executable-sourced
@@ -512,6 +530,7 @@ The auth libraries and applications **must** follow the steps below:
512530

513531
- **2021-12-10**: Add AIP for External Account Credentials (AIP 4117).
514532
- **2022-05-18**: Document executable-sourced credentials (AIP 4117).
533+
- **2022-08-31**: Document configurable token lifetime (AIP 4117).
515534

516535
<!-- prettier-ignore-start -->
517536
[0]: https://cloud.google.com/iam/docs/configuring-workload-identity-federation#aws

0 commit comments

Comments
 (0)