Use ENVAR for service account impersonation #809
Labels
priority: p3
Desirable enhancement or fix. May not be included in next release.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
Is your feature request related to a problem? Please describe.
Simpler, environment wide way to impersonate a service account across multiple client libraries during development when my the local machines ADC is set to a user google account (or a service account) with permissions to act as the specified service account.
Google's best practices also recommend service account impersonation.
Describe the solution you'd like
To use an envar to specify a service account email to be used for client library authentication.
Describe alternatives you've considered
gcloud auth application-default login --impersonate-service-account=<>
) - pain to have to run that each time you need to target a certain service account (and I think it still needstargetScopes
to be specified).authorized_user
credentials without a quota project needing it to be specified (which is added boilerplate).GoogleAuth
(which has been created with anImpersonated
authClient
option) using theauthClient
when creating each client library - just extra boilerplate to do for each client.GOOGLE_APPLICATION_CREDENTIALS
envar to the file local before starting - I don't want to have service account key files downloaded.Additional context
Currently if no
authClient
is provided to aService
(and any inherited services,Storage
for example) it just loads up a standardGoogleAuth
object, as below:nodejs-common/src/util.ts
Lines 606 to 617 in 43bfde7
The improvement would be, instead of falling back to a normal
GoogleAuth
above, it could check for the envar and useImpersonated
for example:It wouldn't break anything for people already using a specified
GoogleAuth
ingoogleAutoAuthConfig.authClient
, even with the envar set.I've used the
gcloud
envar for service account impersonation just for an example.Also I've noticed
gcloud
logs out warnings when using the--impersonated-service-account
option - that could be added here too, to warn the user what's happening?Note - I'm not sure if this should be raised here or in
google-auth-library
when tries to load things inGoogleAuth
, but I can see where could possible fit in here so thought I'd start by raising it here... (It would probably be more useful if it could be done at thegoogle-auth-library
level as then if you created aGoogleAuth
it would automatically be impersonated, but then if you're dropping to thegoogle-auth-library
level (and not using a client library) you're possibly doing something a bit more "custom" and can just handle it yourself when creating theGoogleAuth
).The text was updated successfully, but these errors were encountered: