You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[Accessing resources using an OIDC or SAML 2.0 identity provider](#accessing-resources-using-an-oidc-or-saml-20-identity-provider)
34
+
*[Accessing resources using Executable-sourced credentials](#using-executable-sourced-workforce-credentials-with-oidc-and-saml)
32
35
*[Downscoping with Credential Access Boundaries](#downscoping-with-credential-access-boundaries)
33
36
*[Configuring a Proxy](#configuring-a-proxy)
34
37
*[Using Credentials with google-http-client](#using-credentials-with-google-http-client)
@@ -446,14 +449,15 @@ All response types must include both the `version` and `success` fields.
446
449
447
450
The library will populate the following environment variables when the executable is run:
448
451
*`GOOGLE_EXTERNAL_ACCOUNT_AUDIENCE`: The audience field from the credential configuration. Always present.
452
+
*`GOOGLE_EXTERNAL_ACCOUNT_TOKEN_TYPE`: This expected subject token type. Always present.
449
453
*`GOOGLE_EXTERNAL_ACCOUNT_IMPERSONATED_EMAIL`: The service account email. Only present when service account impersonation is used.
450
454
*`GOOGLE_EXTERNAL_ACCOUNT_OUTPUT_FILE`: The output file location from the credential configuration. Only present when specified in the credential configuration.
451
455
452
456
These environment variables can be used by the executable to avoid hard-coding these values.
453
457
454
458
##### Security considerations
455
459
The following security practices are highly recommended:
456
-
* Access to the script should be restricted as it will be displaying credentials to stdout. This ensures that rogue processes do not gain access to the script.
460
+
* Access to the script should be restricted as it will be displaying credentials to stdout. This ensures that rogue processes do not gain access to the script.
457
461
* The configuration file should not be modifiable. Write access should be restricted to avoid processes modifying the executable command portion.
458
462
459
463
Given the complexity of using executable-sourced credentials, it is recommended to use
@@ -463,13 +467,207 @@ credentials unless they do not meet your specific requirements.
463
467
You can now [use the Auth library](#using-external-identities) to call Google Cloud
464
468
resources from an OIDC or SAML provider.
465
469
466
-
#### Using External Identities
470
+
###Workforce Identity Federation
467
471
468
-
External identities (AWS, Azure, and OIDC-based providers) can be used with
469
-
`Application Default Credentials`. In order to use external identities with Application Default
470
-
Credentials, you need to generate the JSON credentials configuration file for your external identity
471
-
as described above. Once generated, store the path to this file in the
# Optional arguments for file types. Default is "text":
516
+
# --credential-source-type "json" \
517
+
# Optional argument for the field that contains the OIDC credential.
518
+
# This is required for json.
519
+
# --credential-source-field-name "id_token" \
520
+
--output-file=/path/to/generated/config.json
521
+
```
522
+
Where the following variables need to be substituted:
523
+
-`$WORKFORCE_POOL_ID`: The workforce pool ID.
524
+
-`$PROVIDER_ID`: The provider ID.
525
+
-`$PATH_TO_OIDC_ID_TOKEN`: The file path used to retrieve the OIDC token.
526
+
-`$WORKFORCE_POOL_USER_PROJECT`: The project number associated with the [workforce pools user project](https://cloud.google.com/iam/docs/workforce-identity-federation#workforce-pools-user-project).
527
+
528
+
To generate a file-sourced SAML configuration, run the following command:
529
+
530
+
```bash
531
+
# Generate a SAML configuration file for file-sourced credentials.
Where the following variables need to be substituted:
541
+
-`$WORKFORCE_POOL_ID`: The workforce pool ID.
542
+
-`$PROVIDER_ID`: The provider ID.
543
+
-`$PATH_TO_SAML_ASSERTION`: The file path used to retrieve the base64-encoded SAML assertion.
544
+
-`$WORKFORCE_POOL_USER_PROJECT`: The project number associated with the [workforce pools user project](https://cloud.google.com/iam/docs/workforce-identity-federation#workforce-pools-user-project).
545
+
546
+
These commands generate the configuration file in the specified output file.
547
+
548
+
**URL-sourced credentials**
549
+
For URL-sourced credentials, a local server needs to host a GET endpoint to return the OIDC token.
550
+
The response can be in plain text or JSON. Additional required request headers can also be
551
+
specified.
552
+
553
+
To generate a URL-sourced OIDC workforce identity configuration, run the following command:
554
+
555
+
```bash
556
+
# Generate an OIDC configuration file for URL-sourced credentials.
Where the following variables need to be substituted:
567
+
-`$WORKFORCE_POOL_ID`: The workforce pool ID.
568
+
-`$PROVIDER_ID`: The provider ID.
569
+
-`$URL_TO_RETURN_OIDC_ID_TOKEN`: The URL of the local server endpoint.
570
+
-`$HEADER_KEY` and `$HEADER_VALUE`: The additional header key/value pairs to pass along the GET request to
571
+
`$URL_TO_GET_OIDC_TOKEN`, e.g. `Metadata-Flavor=Google`.
572
+
-`$WORKFORCE_POOL_USER_PROJECT`: The project number associated with the [workforce pools user project](https://cloud.google.com/iam/docs/workforce-identity-federation#workforce-pools-user-project).
573
+
574
+
To generate a URL-sourced SAML configuration, run the following command:
575
+
576
+
```bash
577
+
# Generate a SAML configuration file for file-sourced credentials.
These commands generate the configuration file in the specified output file.
588
+
589
+
Where the following variables need to be substituted:
590
+
-`$WORKFORCE_POOL_ID`: The workforce pool ID.
591
+
-`$PROVIDER_ID`: The provider ID.
592
+
-`$URL_TO_GET_SAML_ASSERTION`: The URL of the local server endpoint.
593
+
-`$HEADER_KEY` and `$HEADER_VALUE`: The additional header key/value pairs to pass along the GET request to
594
+
`$URL_TO_GET_SAML_ASSERTION`, e.g. `Metadata-Flavor=Google`.
595
+
-`$WORKFORCE_POOL_USER_PROJECT`: The project number associated with the [workforce pools user project](https://cloud.google.com/iam/docs/workforce-identity-federation#workforce-pools-user-project).
596
+
597
+
#### Using Executable-sourced workforce credentials with OIDC and SAML
598
+
599
+
**Executable-sourced credentials**
600
+
For executable-sourced credentials, a local executable is used to retrieve the 3rd party token.
601
+
The executable must handle providing a valid, unexpired OIDC ID token or SAML assertion in JSON format
602
+
to stdout.
603
+
604
+
To use executable-sourced credentials, the `GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES`
605
+
environment variable must be set to `1`.
606
+
607
+
To generate an executable-sourced workforce identity configuration, run the following command:
608
+
609
+
```bash
610
+
# Generate a configuration file for executable-sourced credentials.
Where the following variables need to be substituted:
626
+
-`$WORKFORCE_POOL_ID`: The workforce pool ID.
627
+
-`$PROVIDER_ID`: The provider ID.
628
+
-`$SUBJECT_TOKEN_TYPE`: The subject token type.
629
+
-`$EXECUTABLE_COMMAND`: The full command to run, including arguments. Must be an absolute path to the program.
630
+
-`$WORKFORCE_POOL_USER_PROJECT`: The project number associated with the [workforce pools user project](https://cloud.google.com/iam/docs/workforce-identity-federation#workforce-pools-user-project).
631
+
632
+
The `--executable-timeout-millis` flag is optional. This is the duration for which
633
+
the auth library will wait for the executable to finish, in milliseconds.
634
+
Defaults to 30 seconds when not provided. The maximum allowed value is 2 minutes.
635
+
The minimum is 5 seconds.
636
+
637
+
The `--executable-output-file` flag is optional. If provided, the file path must
638
+
point to the 3rd party credential response generated by the executable. This is useful
639
+
for caching the credentials. By specifying this path, the Auth libraries will first
640
+
check for its existence before running the executable. By caching the executable JSON
641
+
response to this file, it improves performance as it avoids the need to run the executable
642
+
until the cached credentials in the output file are expired. The executable must
643
+
handle writing to this file - the auth libraries will only attempt to read from
644
+
this location. The format of contents in the file should match the JSON format
645
+
expected by the executable shown below.
646
+
647
+
To retrieve the 3rd party token, the library will call the executable
648
+
using the command specified. The executable's output must adhere to the response format
649
+
specified below. It must output the response to stdout.
650
+
651
+
Refer to the [using executable-sourced credentials with Workload Identity Federation](#using-executable-sourced-credentials-with-oidc-and-saml)
652
+
above for the executable response specification.
653
+
654
+
##### Security considerations
655
+
The following security practices are highly recommended:
656
+
* Access to the script should be restricted as it will be displaying credentials to stdout. This ensures that rogue processes do not gain access to the script.
657
+
* The configuration file should not be modifiable. Write access should be restricted to avoid processes modifying the executable command portion.
658
+
659
+
Given the complexity of using executable-sourced credentials, it is recommended to use
660
+
the existing supported mechanisms (file-sourced/URL-sourced) for providing 3rd party
661
+
credentials unless they do not meet your specific requirements.
662
+
663
+
You can now [use the Auth library](#using-external-identities) to call Google Cloud
664
+
resources from an OIDC or SAML provider.
665
+
666
+
### Using External Identities
667
+
668
+
External identities can be used with `Application Default Credentials`. In order to use external identities with
669
+
Application Default Credentials, you need to generate the JSON credentials configuration file for your external identity
670
+
as described above. Once generated, store the path to this file in the`GOOGLE_APPLICATION_CREDENTIALS` environment variable.
0 commit comments