Skip to content

Commit ebf5e6d

Browse files
fix: add new system property (com.google.cloud.storage.grpc.bound_token) to allow disabling bound token use with grpc (#3365)
Co-authored-by: BenWhitehead <[email protected]>
1 parent 763be91 commit ebf5e6d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcStorageOptions.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ public final class GrpcStorageOptions extends StorageOptions
134134
private static final String GCS_SCOPE = "https://www.googleapis.com/auth/devstorage.full_control";
135135
private static final Set<String> SCOPES = ImmutableSet.of(GCS_SCOPE);
136136
private static final String DEFAULT_HOST = "https://storage.googleapis.com";
137+
// If true, disable the bound-token-by-default feature for DirectPath.
138+
private static final boolean DIRECT_PATH_BOUND_TOKEN_DISABLED =
139+
Boolean.parseBoolean(
140+
System.getProperty("com.google.cloud.storage.grpc.bound_token", "false"));
137141

138142
private final GrpcRetryAlgorithmManager retryAlgorithmManager;
139143
private final java.time.Duration terminationAwaitDuration;
@@ -318,10 +322,12 @@ private Tuple<StorageSettings, Opts<UserProject>> resolveSettingsAndOpts() throw
318322
InstantiatingGrpcChannelProvider.newBuilder()
319323
.setEndpoint(endpoint)
320324
.setAllowNonDefaultServiceAccount(true)
321-
.setAttemptDirectPath(attemptDirectPath)
322-
.setAllowHardBoundTokenTypes(
323-
Collections.singletonList(
324-
InstantiatingGrpcChannelProvider.HardBoundTokenTypes.ALTS));
325+
.setAttemptDirectPath(attemptDirectPath);
326+
327+
if (!DIRECT_PATH_BOUND_TOKEN_DISABLED) {
328+
channelProviderBuilder.setAllowHardBoundTokenTypes(
329+
Collections.singletonList(InstantiatingGrpcChannelProvider.HardBoundTokenTypes.ALTS));
330+
}
325331

326332
if (!NoopGrpcInterceptorProvider.INSTANCE.equals(grpcInterceptorProvider)) {
327333
channelProviderBuilder.setInterceptorProvider(grpcInterceptorProvider);

0 commit comments

Comments
 (0)