-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(auth): add universe domain support to idtoken #11059
base: main
Are you sure you want to change the base?
Conversation
ee34736
to
260aaaa
Compare
2b32c34
to
06969bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM to me overall. Just refactor a little to remove some now unnecessary structs.
// This TokenProvider is primarily intended for use in non-GDU universes, which | ||
// do not have access to the oauth2.googleapis.com/token endpoint, and thus must | ||
// use IAM generateIdToken instead. | ||
type iamIDTokenProvider struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this struct can go away completely. should now be able to use impersonate.IDTokenIAMOptions directly.
type impersonatedIDTokenProvider struct { | ||
client *http.Client | ||
logger *slog.Logger | ||
client *http.Client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with my other comment, this structure should go away in favor of the common code
Summary
IdToken flow can be done in two ways: 1) OAuth2 server calls or 2) IAM service calls. The majority of implementations went with the OAuth2 server calls. In non-GDU environments, however, there is no OAuth2 server, so the IAM implementation must be used. This is enabled as follows:
impersonatedIDTokenProvider.Token
inauth/credentials/impersonate/idtoken.go
toIDTokenIAMOptions.Token
inauth/credentials/internal/impersonate/idtoken.go
to enable reuse inauth/credentials/idtoken/iam.go
.formatIAMServiceAccountName
inauth/credentials/impersonate/impersonate.go
toFormatIAMServiceAccountResource
inauth/internal/internal.go
, for reuse.auth/credentials/idtoken/file.go
introduce a conditional (resolveUniverseDomain(f) == internal.DefaultUniverseDomain
) which if true sustains the existing behavior (auth.New2LOTokenProvider
) and if false introduces the new non-GDU behavior inIDTokenIAMOptions.Token
Note that to use the IAM endpoint in a non-GDU environment, the service account must have the
iam.serviceAccountTokenCreator
role because the service account is not only the target service account, but also the caller; the Oauth2 endpoint doesn’t need this.