Skip to content
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

grpc: create new ComputeEngineCredentials via newBuilder. #3651

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rmehta19
Copy link
Contributor

@rmehta19 rmehta19 commented Feb 22, 2025

@rockspore pointed out that the credential should be created from scratch because when using toBuilder the underlying access token is copied.

This was confirmed to be a bug with local testing which:

  • deployed a GAE app
  • create Google API client ( allowedHardBoundAccessTokens empty in GrpcProvider) and then ping the API, logs show the bearer token is used, obtained from making call to MDS
  • create a Google API client ( allowedHardBoundAccessTokens contains MTLS_S2A in GrpcProvider) and then ping the API, logs show the bearer token is used. A call to MDS is not made.

This is likely because the credential and channel have different lifetimes.

@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Feb 22, 2025
@rmehta19 rmehta19 changed the title fix: create new ComputeEngineCredentials via newBuilder. grpc fix: create new ComputeEngineCredentials via newBuilder. Feb 22, 2025
@@ -1199,14 +1199,18 @@ boolean isDirectPathBoundTokenEnabled() {
CallCredentials createHardBoundTokensCallCredentials(
ComputeEngineCredentials.GoogleAuthTransport googleAuthTransport,
ComputeEngineCredentials.BindingEnforcement bindingEnforcement) {
ComputeEngineCredentials.Builder credsBuilder =
((ComputeEngineCredentials) credentials).toBuilder();
// We only set scopes and HTTP transport factory from the original credentials because
Copy link
Member

@rockspore rockspore Feb 22, 2025

Choose a reason for hiding this comment

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

For future readers, could you explain briefly in the comment why we create it from a newBuilder()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Done.

@product-auto-label product-auto-label bot added size: xs Pull request size is extra small. and removed size: s Pull request size is small. labels Feb 22, 2025
@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: xs Pull request size is extra small. labels Feb 22, 2025
@rmehta19 rmehta19 changed the title grpc fix: create new ComputeEngineCredentials via newBuilder. grpc: create new ComputeEngineCredentials via newBuilder. Feb 22, 2025
@rmehta19
Copy link
Contributor Author

@lqiu96 , please review, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants