Skip to content
This repository was archived by the owner on May 12, 2026. It is now read-only.

feat: Support retrieving ID Token from IAM endpoint for ServiceAccountCredentials - #1433

Merged
lqiu96 merged 14 commits into
mainfrom
id_token_support
Aug 29, 2024
Merged

lqiu96 merged 14 commits into
mainfrom
id_token_support

Conversation

@lqiu96

@lqiu96 lqiu96 commented Jul 9, 2024 •

Copy link
Copy Markdown
Member

See b/340613207 for more information.

@product-auto-label product-auto-label Bot added the size: m Pull request size is medium. label Jul 9, 2024
@product-auto-label product-auto-label Bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Jul 10, 2024
@product-auto-label product-auto-label Bot added size: m Pull request size is medium. and removed size: l Pull request size is large. labels Jul 10, 2024
@product-auto-label product-auto-label Bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Jul 11, 2024

@zhumin8 zhumin8 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The high level logic seems reasonable to me, still trying to get a better understanding of the id-token workflow. I will give it a second try after I do some readings on the context.

Comment thread oauth2_http/java/com/google/auth/oauth2/ServiceAccountCredentials.java Outdated

@Test
public void idTokenWithAudience_incorrect() throws IOException {
public void idTokenWithAudience_oauthFlow_incorrect() throws IOException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like idTokenWithAudience_oauthFlow_incorrectAudience() to be more specific on the test?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, will update!

@lqiu96
lqiu96 marked this pull request as ready for review July 11, 2024 21:08
@lqiu96
lqiu96 requested a review from a team July 11, 2024 21:08

@zhumin8 zhumin8 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
only a few nit picks.

String assertion =
createAssertionForIdToken(
jsonFactory, currentTime, tokenServerUri.toString(), targetAudience);
createAssertionForIdToken(currentTime, tokenServerUri.toString(), targetAudience);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability, perhaps rename tokenServerUri tooauthIdTokenUri in parallel to iamIdTokenUri?

@lqiu96 lqiu96 Jul 23, 2024 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tokenServerUri has getters and setters that match the variable name. I think it would be too confusing to change the variable name.

Comment on lines +628 to +631
URI iamIdTokenUri =
URI.create(
String.format(
OAuth2Utils.IAM_ID_TOKEN_ENDPOINT_FORMAT, getUniverseDomain(), clientEmail));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can we be consistent with iamIdTokenUri and tokenServerUri? either both declare as class variable or both inside respective get endpoint method.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tokenServerUri is a customizable from setters and can't be declared as a class variable. iamIdTokenUri probably can be initialized in the constructor and I'll move it up there.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, getUniverseDomain() throws an IOException and adding a checked exception to the constructor is a breaking change. I think it would be better to leave it here.

@sonarqubecloud

Copy link
Copy Markdown

@lqiu96
lqiu96 requested a review from westarle July 31, 2024 21:55

@arithmetic1728 arithmetic1728 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sonarqubecloud

Copy link
Copy Markdown

@lqiu96
lqiu96 merged commit 4fcf83e into main Aug 29, 2024
@lqiu96
lqiu96 deleted the id_token_support branch August 29, 2024 15:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants