|
4 | 4 |
|
5 | 5 | // Package google provides support for making OAuth2 authorized and authenticated |
6 | 6 | // HTTP requests to Google APIs. It supports the Web server flow, client-side |
7 | | -// credentials, service accounts, Google Compute Engine service accounts, and Google |
8 | | -// App Engine service accounts. |
| 7 | +// credentials, service accounts, Google Compute Engine service accounts, Google |
| 8 | +// App Engine service accounts and workload identity federation from non-Google |
| 9 | +// cloud platforms. |
9 | 10 | // |
10 | 11 | // A brief overview of the package follows. For more information, please read |
11 | 12 | // https://developers.google.com/accounts/docs/OAuth2 |
12 | 13 | // and |
13 | 14 | // https://developers.google.com/accounts/docs/application-default-credentials. |
| 15 | +// For more information on using workload identity federation, refer to |
| 16 | +// https://cloud.google.com/iam/docs/how-to#using-workload-identity-federation. |
14 | 17 | // |
15 | 18 | // OAuth2 Configs |
16 | 19 | // |
|
19 | 22 | // the other by JWTConfigFromJSON. The returned Config can be used to obtain a TokenSource or |
20 | 23 | // create an http.Client. |
21 | 24 | // |
| 25 | +// Workload Identity Federation |
| 26 | +// |
| 27 | +// Using workload identity federation, your application can access Google Cloud |
| 28 | +// resources from Amazon Web Services (AWS), Microsoft Azure or any identity |
| 29 | +// provider that supports OpenID Connect (OIDC). |
| 30 | +// Traditionally, applications running outside Google Cloud have used service |
| 31 | +// account keys to access Google Cloud resources. Using identity federation, |
| 32 | +// you can allow your workload to impersonate a service account. |
| 33 | +// This lets you access Google Cloud resources directly, eliminating the |
| 34 | +// maintenance and security burden associated with service account keys. |
| 35 | +// |
| 36 | +// Follow the detailed instructions on how to configure Workload Identity Federation |
| 37 | +// in various platforms: |
| 38 | +// |
| 39 | +// Amazon Web Services (AWS): https://cloud.google.com/iam/docs/access-resources-aws |
| 40 | +// Microsoft Azure: https://cloud.google.com/iam/docs/access-resources-azure |
| 41 | +// OIDC identity provider: https://cloud.google.com/iam/docs/access-resources-oidc |
| 42 | +// |
| 43 | +// For OIDC providers, the library can retrieve OIDC tokens either from a |
| 44 | +// local file location (file-sourced credentials) or from a local server |
| 45 | +// (URL-sourced credentials). |
| 46 | +// For file-sourced credentials, a background process needs to be continuously |
| 47 | +// refreshing the file location with a new OIDC token prior to expiration. |
| 48 | +// For tokens with one hour lifetimes, the token needs to be updated in the file |
| 49 | +// every hour. The token can be stored directly as plain text or in JSON format. |
| 50 | +// For URL-sourced credentials, a local server needs to host a GET endpoint to |
| 51 | +// return the OIDC token. The response can be in plain text or JSON. |
| 52 | +// Additional required request headers can also be specified. |
| 53 | +// |
22 | 54 | // |
23 | 55 | // Credentials |
24 | 56 | // |
|
29 | 61 | // FindDefaultCredentials looks in some well-known places for a credentials file, and |
30 | 62 | // will call AppEngineTokenSource or ComputeTokenSource as needed. |
31 | 63 | // |
| 64 | +// Application Default Credentials also support workload identity federation to |
| 65 | +// access Google Cloud resources from non-Google Cloud platforms including Amazon |
| 66 | +// Web Services (AWS), Microsoft Azure or any identity provider that supports |
| 67 | +// OpenID Connect (OIDC). Workload identity federation is recommended for |
| 68 | +// non-Google Cloud environments as it avoids the need to download, manage and |
| 69 | +// store service account private keys locally. |
| 70 | +// |
32 | 71 | // DefaultClient and DefaultTokenSource are convenience methods. They first call FindDefaultCredentials, |
33 | 72 | // then use the credentials to construct an http.Client or an oauth2.TokenSource. |
34 | 73 | // |
|
0 commit comments