Conversation
… and clear from sourceCredentials
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates ExternalAccountCredentials to propagate the quotaProjectId to impersonated credentials while clearing it from the source credentials. It also adds a test to verify this behavior. The review feedback correctly identifies a compilation error in the new test method, which needs to declare throws IOException because ExternalAccountCredentials.fromJson throws a checked exception.
| } | ||
|
|
||
| @Test | ||
| void buildImpersonatedCredentials_withQuotaProjectId() { |
Contributor
There was a problem hiding this comment.
The method ExternalAccountCredentials.fromJson throws a checked IOException. Since this exception is not caught within the test method, the method signature must declare throws IOException to avoid a compilation error.
Suggested change
| void buildImpersonatedCredentials_withQuotaProjectId() { | |
| void buildImpersonatedCredentials_withQuotaProjectId() throws IOException { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
When
ExternalAccountCredentials.buildImpersonatedCredentials()creates anImpersonatedCredentialsinstance, it previously leftquotaProjectIdonsourceCredentialsand omitted it onImpersonatedCredentials. As a result,ImpersonatedCredentials.refreshAccessToken()sentx-goog-user-projecton theiamcredentials.googleapis.comgenerateAccessTokenrequest using the federated identity, which fails with403 USER_PROJECT_DENIEDwhen only the impersonated service account hasserviceusage.services.usepermission on the quota project. Meanwhile,ImpersonatedCredentials.getQuotaProjectId()returnednull.This change clears
quotaProjectIdonsourceCredentialsacrossAwsCredentials,PluggableAuthCredentials, andIdentityPoolCredentials, and passesthis.quotaProjectIdtoImpersonatedCredentials.newBuilder().Bug: b/563846713
Testing
mvn test -pl oauth2_http -Dtest=ExternalAccountCredentialsTest,PluggableAuthCredentialsTest,ImpersonatedCredentialsTestcicpclientproj: https://paste.googleplex.com/6012380862087168