Skip to content

Commit c691084

Browse files
committed
adding server_feature in bootstrap config
1 parent c45d8e6 commit c691084

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

internal/xds/bootstrap/bootstrap.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import (
4444

4545
const (
4646
serverFeaturesIgnoreResourceDeletion = "ignore_resource_deletion"
47+
serverFeatureTrustedXDSServer = "trusted_xds_server"
4748
gRPCUserAgentName = "gRPC Go"
4849
clientFeatureNoOverprovisioning = "envoy.lb.does_not_support_overprovisioning"
4950
clientFeatureResourceWrapper = "xds.config.resource-in-sotw"
@@ -256,6 +257,18 @@ func (sc *ServerConfig) ServerFeaturesIgnoreResourceDeletion() bool {
256257
return false
257258
}
258259

260+
// ServerFeaturesTrustedXDSServer returns true if this server is trusted,
261+
// and gRPC should accept security-config-affecting fields from the server
262+
// as described in gRFC A81.
263+
func (sc *ServerConfig) ServerFeaturesTrustedXDSServer() bool {
264+
for _, sf := range sc.serverFeatures {
265+
if sf == serverFeatureTrustedXDSServer {
266+
return true
267+
}
268+
}
269+
return false
270+
}
271+
259272
// SelectedChannelCreds returns the selected credentials configuration for
260273
// communicating with this server.
261274
func (sc *ServerConfig) SelectedChannelCreds() ChannelCreds {

internal/xds/bootstrap/bootstrap_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,22 @@ var (
267267
"server_features" : ["xds_v3"]
268268
}]
269269
}`,
270+
"serverSupportsTrustedXDSServer": `
271+
{
272+
"node": {
273+
"id": "ENVOY_NODE_ID",
274+
"metadata": {
275+
"TRAFFICDIRECTOR_GRPC_HOSTNAME": "trafficdirector"
276+
}
277+
},
278+
"xds_servers" : [{
279+
"server_uri": "trafficdirector.googleapis.com:443",
280+
"channel_creds": [
281+
{ "type": "google_default" }
282+
],
283+
"server_features" : ["trusted_xds_server", "xds_v3"]
284+
}]
285+
}`,
270286
}
271287
metadata = &structpb.Struct{
272288
Fields: map[string]*structpb.Value{
@@ -338,6 +354,16 @@ var (
338354
node: v3Node,
339355
clientDefaultListenerResourceNameTemplate: "%s",
340356
}
357+
configWithGoogleDefaultCredsAndTrustedXDSServer = &Config{
358+
xDSServers: []*ServerConfig{{
359+
serverURI: "trafficdirector.googleapis.com:443",
360+
channelCreds: []ChannelCreds{{Type: "google_default"}},
361+
serverFeatures: []string{"trusted_xds_server", "xds_v3"},
362+
selectedChannelCreds: ChannelCreds{Type: "google_default"},
363+
}},
364+
node: v3Node,
365+
clientDefaultListenerResourceNameTemplate: "%s",
366+
}
341367
configWithGoogleDefaultCredsAndNoServerFeatures = &Config{
342368
xDSServers: []*ServerConfig{{
343369
serverURI: "trafficdirector.googleapis.com:443",
@@ -539,6 +565,7 @@ func (s) TestGetConfiguration_Success(t *testing.T) {
539565
{"goodBootstrap", configWithGoogleDefaultCredsAndV3},
540566
{"multipleXDSServers", configWithMultipleServers},
541567
{"serverSupportsIgnoreResourceDeletion", configWithGoogleDefaultCredsAndIgnoreResourceDeletion},
568+
{"serverSupportsTrustedXDSServer", configWithGoogleDefaultCredsAndTrustedXDSServer},
542569
{"istioStyleInsecureWithoutCallCreds", configWithIstioStyleNoCallCreds},
543570
}
544571

0 commit comments

Comments
 (0)