Use Google Identity Server to Generate JWT for Ambient Credentials #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change set fixes an issue where the access token generated by using ambient credentials with GCP is not compatible with Command. The current code generates only an opaque access token, however Command requires the token be in JWT format.
Google's OAuth SDK does not expose a way to generate an OAuth access token in JWT format. Instead, the only way to produce a valid JWT signed by Google's OAuth server is by producing an ID token. The idtoken flow requires an audience. So, I've introduced a config value for
audiencethat can be optionally set by the end user -- if not set, it will default theaudclaim tocommand.Because we are using an OIDC ID token instead of an OAuth access token, there are slight differences in the JWT produced. For example, the
scopesprovided will not appear in the JWT. However, end users can configure their Command instance to validate claims such asaudandemailto assign identities to roles.