Skip to content

Commit 2d89ab4

Browse files
authored
docs: update user guide to include x509 feature. (#1802)
* docs: update README to include x509 feature. * Fix hyperlink
1 parent 03e640e commit 2d89ab4

File tree

1 file changed

+78
-4
lines changed

1 file changed

+78
-4
lines changed

docs/user-guide.rst

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ credentials.
2323

2424
Credentials from external accounts (workload identity federation) are used to
2525
identify a particular application from an on-prem or non-Google Cloud platform
26-
including Amazon Web Services (AWS), Microsoft Azure or any identity provider
27-
that supports OpenID Connect (OIDC).
26+
including Amazon Web Services (AWS), Microsoft Azure, any identity provider
27+
that supports OpenID Connect (OIDC), or via X.509 certificates.
2828

2929
Obtaining credentials
3030
---------------------
@@ -196,8 +196,8 @@ External credentials (Workload identity federation)
196196
+++++++++++++++++++++++++++++++++++++++++++++++++++
197197

198198
Using workload identity federation, your application can access Google Cloud
199-
resources from Amazon Web Services (AWS), Microsoft Azure or any identity
200-
provider that supports OpenID Connect (OIDC).
199+
resources from Amazon Web Services (AWS), Microsoft Azure, any identity
200+
provider that supports OpenID Connect (OIDC), or via X.509 certificates.
201201

202202
Traditionally, applications running outside Google Cloud have used service
203203
account keys to access Google Cloud resources. Using identity federation,
@@ -290,6 +290,80 @@ Follow the detailed instructions on how to
290290
.. _Configure Workload Identity Federation from an OIDC identity provider:
291291
https://cloud.google.com/iam/docs/access-resources-oidc
292292

293+
.. _accessing-resources-using-x509-certificate-sourced-credentials:
294+
295+
Accessing resources using X.509 certificate-sourced credentials
296+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
297+
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 and must be renewed to maintain access.
298+
299+
The library constructs a subject token by creating a JSON array containing the base64-encoded leaf certificate, followed by any intermediate certificates from a provided trust chain.
300+
301+
**Generating Configuration Files for X.509 Federation**
302+
303+
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 ``gcloud iam workload-identity-pools create-cred-config`` command can be used to create both.
304+
305+
The location where the certificate configuration file is created depends on whether you use the ``--credential-cert-configuration-output-file`` flag.
306+
307+
**Default Behavior (Recommended)**
308+
309+
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.
310+
311+
**Example Command (Default Behavior):**
312+
313+
.. code-block:: bash
314+
315+
gcloud iam workload-identity-pools create-cred-config \
316+
projects/$PROJECT_NUMBER/locations/global/workloadIdentityPools/$POOL_ID/providers/$PROVIDER_ID \
317+
--service-account $SERVICE_ACCOUNT_EMAIL \
318+
--credential-cert-path "$PATH_TO_CERTIFICATE" \
319+
--credential-cert-private-key-path "$PATH_TO_PRIVATE_KEY" \
320+
--credential-cert-trust-chain-path "$PATH_TO_TRUST_CHAIN" \
321+
--output-file /path/to/config.json
322+
323+
Where the following variables need to be substituted:
324+
325+
* ``$PROJECT_NUMBER``: The unique, numerical identifier for your Google Cloud project. This is not the Project ID string.
326+
* ``$POOL_ID``: The workload identity pool ID.
327+
* ``$PROVIDER_ID``: The provider ID.
328+
* ``$SERVICE_ACCOUNT_EMAIL``: The email of the service account to impersonate.
329+
* ``$PATH_TO_CERTIFICATE``: The file path where your leaf X.509 certificate is located.
330+
* ``$PATH_TO_PRIVATE_KEY``: The file path where the corresponding private key for the leaf certificate is located.
331+
* ``$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.
332+
333+
This command results in:
334+
335+
* ``/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.
336+
* ``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.
337+
338+
339+
**Custom Location Behavior**
340+
341+
If you need to store the certificate configuration file in a non-default location, use the ``--credential-cert-configuration-output-file`` flag.
342+
343+
**Example Command (Custom Location):**
344+
345+
.. code-block:: bash
346+
347+
gcloud iam workload-identity-pools create-cred-config \
348+
projects/$PROJECT_NUMBER/locations/global/workloadIdentityPools/$POOL_ID/providers/$PROVIDER_ID \
349+
--service-account $SERVICE_ACCOUNT_EMAIL \
350+
--credential-cert-path "$PATH_TO_CERTIFICATE" \
351+
--credential-cert-private-key-path "$PATH_TO_PRIVATE_KEY" \
352+
--credential-cert-trust-chain-path "$PATH_TO_TRUST_CHAIN" \
353+
--credential-cert-configuration-output-file "/custom/path/cert_config.json" \
354+
--output-file /path/to/config.json
355+
356+
357+
This command results in:
358+
359+
* ``/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.
360+
* ``cert_config.json``: Created at ``/custom/path/cert_config.json``, as specified by the flag.
361+
362+
You can now use the Auth library to call Google Cloud resources with X.509 certificate-sourced credentials.
363+
364+
.. _X.509 certificate-sourced credentials: https://cloud.google.com/iam/docs/workload-identity-federation-with-x509-certificates
365+
366+
293367
Using Executable-sourced credentials with OIDC and SAML
294368
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
295369

0 commit comments

Comments
 (0)