Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1200,11 +1200,20 @@ 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
Member

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.

// only those are used in gRPC CallCredentials to fetch request metadata.
// only those are used in gRPC CallCredentials to fetch request metadata. We create a new
// credential
// via {@code newBuilder} as opposed to {@code toBuilder} because we don't want a reference to
// the
// access token held by {@code credentials}; we want this new credential to fetch a new access
// token
// from MDS using the {@param googleAuthTransport} and {@param bindingEnforcement}.
return MoreCallCredentials.from(
((ComputeEngineCredentials) this.credentials)
.toBuilder()
ComputeEngineCredentials.newBuilder()
.setScopes(credsBuilder.getScopes())
.setHttpTransportFactory(credsBuilder.getHttpTransportFactory())
.setGoogleAuthTransport(googleAuthTransport)
.setBindingEnforcement(bindingEnforcement)
.build());
Expand Down
Loading