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
Copy file name to clipboardExpand all lines: README.md
+74-4Lines changed: 74 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,7 @@ information, refer to [documentation](https://cloud.google.com/docs/authenticati
44
44
*[Accessing resources from AWS](#accessing-resources-from-aws)
45
45
*[Accessing resources from Azure](#access-resources-from-microsoft-azure)
46
46
*[Accessing resources from an OIDC identity provider](#accessing-resources-from-an-oidc-identity-provider)
47
+
*[Accessing resources using X.509 certificate-sourced credentials](#accessing-resources-using-x509-certificate-sourced-credentials)
47
48
*[Accessing resources using Executable-sourced credentials](#using-executable-sourced-credentials-with-oidc-and-saml)
48
49
*[Accessing resources using a custom supplier for OIDC or SAML](#using-a-custom-supplier-with-oidc-and-saml)
49
50
*[Accessing resources using a custom supplier with AWS](#using-a-custom-supplier-with-aws)
@@ -367,10 +368,12 @@ configuration file contains non-sensitive metadata to instruct the library on ho
367
368
retrieve external subject tokens and exchange them for service account access tokens.
368
369
The configuration file can be generated by using the [gcloud CLI](https://cloud.google.com/sdk/).
369
370
370
-
For OIDC providers, the Auth library can retrieve OIDC tokens either from a local file location
371
-
(file-sourced credentials) or from a local server (URL-sourced credentials).
371
+
For OIDC providers, the Auth library can retrieve OIDC tokens from a local file
372
+
([file-sourced credentials](#file-sourced-credentials)), a local server
373
+
([URL-sourced credentials](#url-sourced-credentials)), or a X.509
374
+
certificate and private-key combination (X.509 certificate-sourced credentials).
372
375
373
-
**File-sourced credentials**
376
+
#### File-sourced credentials
374
377
For file-sourced credentials, a background process needs to be continuously refreshing the file
375
378
location with a new OIDC token prior to expiration. For tokens with one hour lifetimes, the token
376
379
needs to be updated in the file every hour. The token can be stored directly as plain text or in
@@ -401,7 +404,7 @@ Where the following variables need to be substituted:
401
404
402
405
This generates the configuration file in the specified output file.
403
406
404
-
**URL-sourced credentials**
407
+
#### URL-sourced credentials
405
408
For URL-sourced credentials, a local server needs to host a GET endpoint to return the OIDC token.
406
409
The response can be in plain text or JSON. Additional required request headers can also be
407
410
specified.
@@ -435,6 +438,73 @@ request to `$URL_TO_GET_OIDC_TOKEN`, e.g. `Metadata-Flavor=Google`.
435
438
You can now [use the Auth library](#using-external-identities) to call Google Cloud
436
439
resources from an OIDC provider.
437
440
441
+
### Accessing resources using X.509 certificate-sourced credentials
442
+
For more information, see the [official documentation](https://cloud.google.com/iam/docs/workload-identity-federation-with-x509-certificates).
443
+
444
+
For X.509 certificate-sourced credentials, the authentication library uses an X.509 certificate and private key to prove your application's identity. The certificate has a built-in expiration date, which is defined in the certificate itself, and must be renewed to maintain access.
445
+
446
+
#### Prerequisites: Generating Configuration Files for X.509 Federation
447
+
To configure X.509 certificate-sourced credentials, you need to generate two separate configuration files: a primary **credential configuration file** and a **certificate configuration file**. The primary credential configuration file contains the necessary metadata for authentication, and it points to the certificate configuration file, which contains the paths to the X.509 certificate, private key, and trust chain.
448
+
449
+
The [`gcloud iam workload-identity-pools create-cred-config`](https://cloud.google.com/sdk/gcloud/reference/iam/workload-identity-pools/create-cred-config) command can be used to create both.
450
+
451
+
The location where the certificate configuration file is created depends on whether you use the `--credential-cert-configuration-output-file` flag.
452
+
453
+
**Default Behavior (Recommended)**
454
+
455
+
If you omit the `--credential-cert-configuration-output-file` flag, gcloud creates the certificate configuration file at a default, well-known location that the auth library can automatically discover. This is the simplest approach for most use cases. The default credential configuration file is named `config.json` and the default certificate configuration file is named `certificate_config.json`.
456
+
457
+
Example Command (Default Behavior):
458
+
459
+
```bash
460
+
gcloud iam workload-identity-pools create-cred-config \
Where the following variables need to be substituted:
470
+
471
+
-`$PROJECT_NUMBER`: The Google Cloud project number.
472
+
-`$POOL_ID`: The workload identity pool ID.
473
+
-`$PROVIDER_ID`: The provider ID.
474
+
-`$SERVICE_ACCOUNT_EMAIL`: The email of the service account to impersonate.
475
+
-`$PATH_TO_CERTIFICATE`: The file path where your leaf X.509 certificate is located.
476
+
-`$PATH_TO_PRIVATE_KEY`: The file path where the corresponding private key for the leaf certificate is located.
477
+
-`$PATH_TO_TRUST_CHAIN`: The file path of the X.509 certificate trust chain file. This file should be a PEM-formatted file containing any intermediate certificates required to complete the trust chain between the leaf certificate and the trust store configured in the Workload Identity Federation pool. The leaf certificate is optional in this file.
478
+
479
+
This command results in:
480
+
481
+
-`/path/to/config.json`: Created at the path you specified. This file will contain `"use_default_certificate_config": true` to instruct clients to look for the certificate configuration at the default path.
482
+
-`certificate_config.json`: Created at the default gcloud configuration path, which is typically `~/.config/gcloud/certificate_config.json` on Linux and macOS, or `%APPDATA%\gcloud\certificate_config.json` on Windows.
483
+
484
+
**Custom Location Behavior**
485
+
486
+
If you need to store the certificate configuration file in a non-default location, use the `--credential-cert-configuration-output-file` flag.
487
+
488
+
Example Command (Custom Location):
489
+
490
+
```bash
491
+
gcloud iam workload-identity-pools create-cred-config \
-`/path/to/config.json`: Created at the path you specified. This file will contain a `"certificate_config_location"` field that points to your custom path.
504
+
-`cert_config.json`: Created at `/custom/path/cert_config.json`, as specified by the flag.
505
+
506
+
You can now [use the Auth library](#using-external-identities) to call Google Cloud resources with X.509 certificate-sourced credentials.
507
+
438
508
#### Using Executable-sourced credentials with OIDC and SAML
0 commit comments