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
AIP 4115/4110: How to retrieve tokens from the metadata server
Add a complete discussion of how auth libraries and workloads should
cache and refresh tokens when loading them from the metadata server.
Existing GCP auth libraries handle this properly, but occasionally it is
not possible or desirable to use a preexisting auth library. This new
section of the AIP provides guidance for those who need to directly
retrieve tokens.
# Default Credentials For Google Cloud Virtual Environments
9
9
10
-
If the client runs on Google cloud virtual environments such as [Google Compute Engine (GCE)][0],
11
-
[Serverless][1], or [Google Kubernetes Engine (GKE)][2], the auth library **may** leverage
12
-
Google’s default mutual TLS (mTLS) credentials and obtain bound tokens for the instance.
13
-
The auth library **may** use the default mTLS credentials and bound tokens to access Google APIs.
14
-
15
-
mTLS authentication enables authentication of both client and server identities in a TLS handshake.
16
-
Applications running in Google virtual environments can authenticate to Google APIs using X.509
17
-
SPIFFE Verifiable Identity Documents (SVIDs). These SVIDs are X.509 certificates that contain SPIFFE
18
-
IDs specifying the identity of the certificate owner.
19
-
20
-
Bound tokens are access tokens that are bound to some property of the credentials used to establish
21
-
the mTLS connection. The advantage of bound tokens is that they can be used over secure channels
22
-
established via mTLS credentials with the correct binding information, when appropriate access
23
-
policies have been put in place. Therefore, using bound tokens is more secure than bearer tokens,
24
-
which can be stolen and adversarially replayed.
10
+
If the client runs on Google cloud compute environments such as [Google Compute
11
+
Engine (GCE)][0], [Serverless][1], or [Google Kubernetes Engine (GKE)][2],
12
+
absent any explicit configuration the auth library will follow the Application
13
+
Default Credentials flow described in AIP-4110. It will detect that it is
14
+
running on a platform with an available metadata server API, and configure
15
+
itself to retrieve workload credentials from the metadata server.
16
+
17
+
Typically, these workload credentials will be Google oauth access tokens, which are opaque tokens (only decodable by Google) that start with the fixed string `ya29.`. Depending on the configuration of the workload and the Google service being called, the auth library may use additional features supported on the metadata server, such as mTLS-bound access tokens.
25
18
26
-
This AIP describes the flow of:
19
+
This AIP describes how to:
27
20
28
-
1.Retrieving a configuration through a metadata server (MDS) endpoint. The configuration specifies
29
-
how to access Google’s default mTLS credentials.
30
-
2. Requesting bound tokens.
21
+
1.Retrieve and cache workload access tokens from the metadata server.
22
+
2. Retrieve mTLS-specific configuration from the metadata server
23
+
3. Request mTLS-bound access tokens from the metadata server.
31
24
32
25
**Note:** Because this AIP describes guidance and requirements in a language-neutral way, it uses
33
26
generic terminology which may be imprecise or inappropriate in certain languages or environments.
34
27
35
28
## Guidance
36
29
30
+
### Metadata Server API
31
+
32
+
The metadata server is a special API that your workload can access using the
33
+
special hostname `metadata.google.internal`. This special hostname is
34
+
configured to resolve to the address `169.254.169.254` across all GCP
35
+
compute environments.
36
+
37
+
The metadata server serves an HTTP API. The precise set of paths available on
38
+
this API is platform-specific, but the main paths used for authenticating to
39
+
Google APIs are
40
+
41
+
#### Workload Access Token
42
+
43
+
The access token endpoint returns an opaque access token that can be used as a bearer token to authenticate to Google APIs.
0 commit comments