Skip to content

Commit 98e5ec2

Browse files
committed
Remove feature guarding of the env vars for Cloud run CSM:
GRPC_EXPERIMENTAL_XDS_SNI GRPC_EXPERIMENTAL_XDS_AUTHORITY_REWRITE GRPC_EXPERIMENTAL_XDS_SYSTEM_ROOT_CERTS GRPC_EXPERIMENTAL_XDS_GCP_AUTHENTICATION_FILTER
1 parent 2360771 commit 98e5ec2

File tree

10 files changed

+172
-346
lines changed

10 files changed

+172
-346
lines changed

xds/src/main/java/io/grpc/xds/FilterRegistry.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package io.grpc.xds;
1818

1919
import com.google.common.annotations.VisibleForTesting;
20-
import io.grpc.internal.GrpcUtil;
2120
import java.util.HashMap;
2221
import java.util.Map;
2322
import javax.annotation.Nullable;
@@ -33,18 +32,13 @@ final class FilterRegistry {
3332

3433
private FilterRegistry() {}
3534

36-
static boolean isEnabledGcpAuthnFilter =
37-
GrpcUtil.getFlag("GRPC_EXPERIMENTAL_XDS_GCP_AUTHENTICATION_FILTER", false);
38-
3935
static synchronized FilterRegistry getDefaultRegistry() {
4036
if (instance == null) {
4137
instance = newRegistry().register(
4238
new FaultFilter.Provider(),
4339
new RouterFilter.Provider(),
44-
new RbacFilter.Provider());
45-
if (isEnabledGcpAuthnFilter) {
46-
instance.register(new GcpAuthenticationFilter.Provider());
47-
}
40+
new RbacFilter.Provider(),
41+
new GcpAuthenticationFilter.Provider());
4842
}
4943
return instance;
5044
}

xds/src/main/java/io/grpc/xds/GcpAuthenticationFilter.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package io.grpc.xds;
1818

1919
import static com.google.common.base.Preconditions.checkNotNull;
20-
import static io.grpc.xds.FilterRegistry.isEnabledGcpAuthnFilter;
2120
import static io.grpc.xds.XdsNameResolver.CLUSTER_SELECTION_KEY;
2221
import static io.grpc.xds.XdsNameResolver.XDS_CONFIG_CALL_OPTION_KEY;
2322

@@ -313,10 +312,6 @@ public String getTypeUrl() {
313312
public AudienceWrapper parse(Any any) throws ResourceInvalidException {
314313
Audience audience;
315314
try {
316-
if (!isEnabledGcpAuthnFilter) {
317-
throw new InvalidProtocolBufferException("Environment variable for GCP Authentication "
318-
+ "Filter is Not Set");
319-
}
320315
audience = any.unpack(Audience.class);
321316
} catch (InvalidProtocolBufferException ex) {
322317
throw new ResourceInvalidException("Invalid Resource in address proto", ex);

xds/src/main/java/io/grpc/xds/XdsClusterResource.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ class XdsClusterResource extends XdsResourceType<CdsUpdate> {
6464
? Boolean.parseBoolean(System.getenv("GRPC_EXPERIMENTAL_ENABLE_LEAST_REQUEST"))
6565
: Boolean.parseBoolean(
6666
System.getProperty("io.grpc.xds.experimentalEnableLeastRequest", "true"));
67-
@VisibleForTesting
68-
public static boolean enableSystemRootCerts =
69-
GrpcUtil.getFlag("GRPC_EXPERIMENTAL_XDS_SYSTEM_ROOT_CERTS", false);
7067
static boolean isEnabledXdsHttpConnect =
7168
GrpcUtil.getFlag("GRPC_EXPERIMENTAL_XDS_HTTP_CONNECT", false);
7269

@@ -486,8 +483,7 @@ static void validateCommonTlsContext(
486483
}
487484
String rootCaInstanceName = getRootCertInstanceName(commonTlsContext);
488485
if (rootCaInstanceName == null) {
489-
if (!server && (!enableSystemRootCerts
490-
|| !CommonTlsContextUtil.isUsingSystemRootCerts(commonTlsContext))) {
486+
if (!server && !CommonTlsContextUtil.isUsingSystemRootCerts(commonTlsContext)) {
491487
throw new ResourceInvalidException(
492488
"ca_certificate_provider_instance or system_root_certs is required in "
493489
+ "upstream-tls-context");

xds/src/main/java/io/grpc/xds/XdsRouteConfigureResource.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,7 @@ static StructOrError<RouteAction> parseRouteAction(
475475
case CLUSTER:
476476
return StructOrError.fromStruct(RouteAction.forCluster(
477477
proto.getCluster(), hashPolicies, timeoutNano, retryPolicy,
478-
GrpcUtil.getFlag(GRPC_EXPERIMENTAL_XDS_AUTHORITY_REWRITE, false)
479-
&& args.getServerInfo().isTrustedXdsServer() && proto.getAutoHostRewrite().getValue()));
478+
args.getServerInfo().isTrustedXdsServer() && proto.getAutoHostRewrite().getValue()));
480479
case CLUSTER_HEADER:
481480
return null;
482481
case WEIGHTED_CLUSTERS:
@@ -510,8 +509,7 @@ static StructOrError<RouteAction> parseRouteAction(
510509
}
511510
return StructOrError.fromStruct(VirtualHost.Route.RouteAction.forWeightedClusters(
512511
weightedClusters, hashPolicies, timeoutNano, retryPolicy,
513-
GrpcUtil.getFlag(GRPC_EXPERIMENTAL_XDS_AUTHORITY_REWRITE, false)
514-
&& args.getServerInfo().isTrustedXdsServer() && proto.getAutoHostRewrite().getValue()));
512+
args.getServerInfo().isTrustedXdsServer() && proto.getAutoHostRewrite().getValue()));
515513
case CLUSTER_SPECIFIER_PLUGIN:
516514
if (enableRouteLookup) {
517515
String pluginName = proto.getClusterSpecifierPlugin();
@@ -527,8 +525,7 @@ static StructOrError<RouteAction> parseRouteAction(
527525
NamedPluginConfig namedPluginConfig = NamedPluginConfig.create(pluginName, pluginConfig);
528526
return StructOrError.fromStruct(VirtualHost.Route.RouteAction.forClusterSpecifierPlugin(
529527
namedPluginConfig, hashPolicies, timeoutNano, retryPolicy,
530-
GrpcUtil.getFlag(GRPC_EXPERIMENTAL_XDS_AUTHORITY_REWRITE, false)
531-
&& args.getServerInfo().isTrustedXdsServer()
528+
args.getServerInfo().isTrustedXdsServer()
532529
&& proto.getAutoHostRewrite().getValue()));
533530
} else {
534531
return null;

xds/src/main/java/io/grpc/xds/internal/security/SecurityProtocolNegotiators.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,16 @@ public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
215215
this.sslContextProviderSupplier = sslContextProviderSupplier;
216216
EnvoyServerProtoData.BaseTlsContext tlsContext = sslContextProviderSupplier.getTlsContext();
217217
UpstreamTlsContext upstreamTlsContext = ((UpstreamTlsContext) tlsContext);
218-
if (CertificateUtils.isXdsSniEnabled) {
219-
String sniToUse = upstreamTlsContext.getAutoHostSni()
220-
&& !Strings.isNullOrEmpty(endpointHostname)
221-
? endpointHostname : upstreamTlsContext.getSni();
222-
if (sniToUse.isEmpty() && CertificateUtils.useChannelAuthorityIfNoSniApplicable) {
223-
sniToUse = grpcHandler.getAuthority();
224-
autoSniSanValidationDoesNotApply = true;
225-
} else {
226-
autoSniSanValidationDoesNotApply = false;
227-
}
228-
sni = sniToUse;
218+
String sniToUse = upstreamTlsContext.getAutoHostSni()
219+
&& !Strings.isNullOrEmpty(endpointHostname)
220+
? endpointHostname : upstreamTlsContext.getSni();
221+
if (sniToUse.isEmpty() && CertificateUtils.useChannelAuthorityIfNoSniApplicable) {
222+
sniToUse = grpcHandler.getAuthority();
223+
autoSniSanValidationDoesNotApply = true;
229224
} else {
230-
sni = grpcHandler.getAuthority();
231225
autoSniSanValidationDoesNotApply = false;
232226
}
227+
sni = sniToUse;
233228
}
234229

235230
@VisibleForTesting

xds/src/main/java/io/grpc/xds/internal/security/trust/XdsX509TrustManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ public void checkServerTrusted(X509Certificate[] chain, String authType)
308308

309309
private List<StringMatcher> getAutoSniSanMatchers(SSLParameters sslParams) {
310310
List<StringMatcher> sniNamesToMatch = new ArrayList<>();
311-
if (CertificateUtils.isXdsSniEnabled && autoSniSanValidation) {
311+
if (autoSniSanValidation) {
312312
List<SNIServerName> serverNames = sslParams.getServerNames();
313313
if (serverNames != null) {
314314
for (SNIServerName serverName : serverNames) {

xds/src/test/java/io/grpc/xds/GcpAuthenticationFilterTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ public class GcpAuthenticationFilterTest {
8888
private static final RdsUpdate rdsUpdate = getRdsUpdate();
8989
private static final CdsUpdate cdsUpdate = getCdsUpdate();
9090

91-
@Before
92-
public void setUp() {
93-
System.setProperty("GRPC_EXPERIMENTAL_XDS_GCP_AUTHENTICATION_FILTER", "true");
94-
}
95-
9691
@Test
9792
public void testNewFilterInstancesPerFilterName() {
9893
assertThat(new GcpAuthenticationFilter("FILTER_INSTANCE_NAME1", 10))

0 commit comments

Comments
 (0)