Skip to content

Commit 03753f5

Browse files
authored
creds/google: fix CFE cluster name check (#4893)
1 parent 4f21cde commit 03753f5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

credentials/google/google_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestClientHandshakeBasedOnClusterName(t *testing.T) {
101101
{
102102
name: "with CFE cluster name",
103103
ctx: icredentials.NewClientHandshakeInfoContext(context.Background(), credentials.ClientHandshakeInfo{
104-
Attributes: internal.SetXDSHandshakeClusterName(resolver.Address{}, cfeClusterName).Attributes,
104+
Attributes: internal.SetXDSHandshakeClusterName(resolver.Address{}, "google_cfe_bigtable.googleapis.com").Attributes,
105105
}),
106106
// CFE should use tls.
107107
wantTyp: "tls",

credentials/google/xds.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,19 @@ package google
2121
import (
2222
"context"
2323
"net"
24+
"strings"
2425

2526
"google.golang.org/grpc/credentials"
2627
"google.golang.org/grpc/internal"
2728
)
2829

29-
const cfeClusterName = "google-cfe"
30+
const cfeClusterNamePrefix = "google_cfe_"
3031

3132
// clusterTransportCreds is a combo of TLS + ALTS.
3233
//
3334
// On the client, ClientHandshake picks TLS or ALTS based on address attributes.
3435
// - if attributes has cluster name
35-
// - if cluster name is "google_cfe", use TLS
36+
// - if cluster name has prefix "google_cfe_", use TLS
3637
// - otherwise, use ALTS
3738
// - else, do TLS
3839
//
@@ -55,7 +56,7 @@ func (c *clusterTransportCreds) ClientHandshake(ctx context.Context, authority s
5556
return c.tls.ClientHandshake(ctx, authority, rawConn)
5657
}
5758
cn, ok := internal.GetXDSHandshakeClusterName(chi.Attributes)
58-
if !ok || cn == cfeClusterName {
59+
if !ok || strings.HasPrefix(cn, cfeClusterNamePrefix) {
5960
return c.tls.ClientHandshake(ctx, authority, rawConn)
6061
}
6162
// If attributes have cluster name, and cluster name is not cfe, it's a

0 commit comments

Comments
 (0)