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

fix: S2A gRPC flow creates ComputeEngineCredentials via newBuilder. #3651

Merged
merged 5 commits into from
Feb 24, 2025

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, the app performs the below two actions sequentially
  • 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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yes thanks! This is an known issue in the Auth Library that we're slowly trying to fix as well and sorry to see that this also bit you all.

The existing access token will be invalidated (not copied) in the future from the builder.

@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!

@lqiu96
Copy link
Contributor

lqiu96 commented Feb 24, 2025

/gcbrun

@lqiu96
Copy link
Contributor

lqiu96 commented Feb 24, 2025

Oh, can you also rename the title to follow conventional commits?

fix: S2A gRPC flow creates ComputeEngineCredentials via newBuilder.

or some similar

@rmehta19 rmehta19 changed the title grpc: create new ComputeEngineCredentials via newBuilder. fix: S2A gRPC flow creates ComputeEngineCredentials via newBuilder. Feb 24, 2025
@rmehta19
Copy link
Contributor Author

Thanks @lqiu96 . I also updated the branch with upstream main, I think you will have to rerun gcbrun?

@lqiu96
Copy link
Contributor

lqiu96 commented Feb 24, 2025

/gcbrun

@lqiu96 lqiu96 enabled auto-merge (squash) February 24, 2025 21:57
@lqiu96 lqiu96 merged commit 29c061e into googleapis:main Feb 24, 2025
45 of 47 checks passed
JoeWang1127 added a commit that referenced this pull request Feb 25, 2025
🤖 I have created a release *beep* *boop*
---


<details><summary>2.54.0</summary>

##
[2.54.0](v2.53.0...v2.54.0)
(2025-02-25)


### Features

* add client side logging with slf4j
([#3403](#3403))
([fe002fa](fe002fa))


### Bug Fixes

* S2A gRPC flow creates ComputeEngineCredentials via newBuilder.
([#3651](#3651))
([29c061e](29c061e))


### Dependencies

* update dependency ch.qos.logback:logback-core to v1.3.15 [security]
([#3654](#3654))
([093d867](093d867))
* update google api dependencies
([#3631](#3631))
([48db2a1](48db2a1))
* update google auth library dependencies to v1.33.1
([#3656](#3656))
([f7877a5](f7877a5))
* update google http client dependencies to v1.46.3
([#3657](#3657))
([9d5b3b5](9d5b3b5))
* update grpc to 1.70.0
([#3641](#3641))
([ad26cf9](ad26cf9))
* update grpc to 1.70.0 (missed update)
([#3658](#3658))
([6ca0599](6ca0599))
* Update opentelemetry-semconv to v1.29.0-alpha
([#3635](#3635))
([49ac09d](49ac09d))


### Documentation

* update showcase readme
([#3659](#3659))
([0ddf073](0ddf073))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Joe Wang <[email protected]>
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.

3 participants