Users can't specify non-default scopes for code running on GKE Workload Identity (and possibly AppEngine flex) #458
Labels
feature
fix
priority: p1
Important issue which blocks shipping the next release. Will be fixed prior to next release.
semver: minor
A new feature was added. No breaking changes.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
The ComputeEngineCredentials class is used for pulling access and identity tokens when the library is running on GCE, GKE Workload Identity, and AppEngine flex. It doesn't support setting scopes on the resulting access token, because on GCE scopes are handled by assigning them to the VM.
However, this isn't the case on GKE Workload Identity (and possibly AppEngine flex, I am still confirming this). In this environment, there is no concept of a scope lock or default scopes for the access token. Instead the metadata server accepts a
?scopes
query parameter on the/computeMetadata/v1/instance/service-accounts/default/token
request and creates an access token with the requested scopes.If no
?scopes
are specified, then the returned access tokens has a hardcoded default set of scopes (cloud-platform
anduserInfo.email
).This means that users of ComputeEngineCredentials don't have a way to use non-cloud Google APIs when running on GKE Workload Identity, since non-cloud APIs are not included in the
cloud-platform
access scope.The GCE Metadata Server accepts the
?scopes
parameter without complaint, but ignores it.I'd like to extend the ComputeEngineCredentials class with a
createScoped
implementation that will make a new ComputeEngineCredentials instance that passes the?scopes
query parameter, so that code like this will work when running on GKE Workload Identity:The text was updated successfully, but these errors were encountered: