-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Add flag guarding SPIFFE Bundle provider #8343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
1b6e905
dd60f60
7c30683
fb77e9d
a96c031
94cae8f
1cb982a
2762209
7007700
29e82a3
b78b892
2de3163
b3e092d
b2a6bdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import ( | |
|
||
"github.com/google/go-cmp/cmp" | ||
"google.golang.org/grpc/credentials/tls/certprovider" | ||
"google.golang.org/grpc/internal/envconfig" | ||
"google.golang.org/grpc/internal/grpctest" | ||
"google.golang.org/grpc/internal/testutils" | ||
"google.golang.org/grpc/testdata" | ||
|
@@ -76,6 +77,7 @@ func compareKeyMaterial(got, want *certprovider.KeyMaterial) error { | |
|
||
// TestNewProvider tests the NewProvider() function with different inputs. | ||
func (s) TestNewProvider(t *testing.T) { | ||
testutils.SetEnvConfig(t, &envconfig.XDSSpiffeEnabled, true) | ||
|
||
tests := []struct { | ||
desc string | ||
options Options | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,4 +63,9 @@ var ( | |
// For more details, see: | ||
// https://github.com/grpc/proposal/blob/master/A82-xds-system-root-certs.md. | ||
XDSSystemRootCertsEnabled = boolFromEnv("GRPC_EXPERIMENTAL_XDS_SYSTEM_ROOT_CERTS", false) | ||
|
||
// XDSSpiffeEnabled controls is SPIFFE Bundle Maps can be used as roots of | ||
gtcooke94 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
// trust. For more details, see: | ||
// https://github.com/grpc/proposal/blob/master/A87-mtls-spiffe-support.md | ||
XDSSpiffeEnabled = boolFromEnv("GRPC_EXPERIMENTAL_XDS_MTLS_SPIFFE", false) | ||
gtcooke94 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ import ( | |
"google.golang.org/grpc/credentials/tls/certprovider" | ||
"google.golang.org/grpc/credentials/tls/certprovider/pemfile" | ||
"google.golang.org/grpc/internal/credentials/spiffe" | ||
"google.golang.org/grpc/internal/envconfig" | ||
) | ||
|
||
// bundle is an implementation of credentials.Bundle which implements mTLS | ||
|
@@ -64,6 +65,9 @@ func NewBundle(jd json.RawMessage) (credentials.Bundle, func(), error) { | |
} | ||
} // Else the config field is absent. Treat it as an empty config. | ||
|
||
if !envconfig.XDSSpiffeEnabled { | ||
|
||
cfg.SPIFFETrustBundleMapFile = "" | ||
} | ||
if cfg.CACertificateFile == "" && cfg.CertificateFile == "" && cfg.PrivateKeyFile == "" && cfg.SPIFFETrustBundleMapFile == "" { | ||
// We cannot use (and do not need) a file_watcher provider in this case, | ||
// and can simply directly use the TLS transport credentials. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ import ( | |
|
||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/internal/envconfig" | ||
"google.golang.org/grpc/internal/grpctest" | ||
"google.golang.org/grpc/internal/stubserver" | ||
"google.golang.org/grpc/internal/testutils" | ||
|
@@ -237,6 +238,7 @@ func (s) TestCaReloading(t *testing.T) { | |
// is performed and checked for failure, ensuring that gRPC is correctly using | ||
// the changed-on-disk bundle map. | ||
func (s) Test_SPIFFE_Reloading(t *testing.T) { | ||
testutils.SetEnvConfig(t, &envconfig.XDSSpiffeEnabled, true) | ||
|
||
clientSPIFFEBundle, err := os.ReadFile(testdata.Path("spiffe_end2end/client_spiffebundle.json")) | ||
if err != nil { | ||
t.Fatalf("Failed to read test SPIFFE bundle: %v", err) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My reading of this sentence from the gRFC is that we don't even read the new field
spiffe_trust_bundle_map_file
from the bootstrap. So, this might need to be handled incertprovider/pemfile/builder.go
inpluginConfigFromJSON
instead of here. Because by the time we get here, we have already read the field from the bootstrap JSON."""
The xDS functionality will be guarded via the GRPC_EXPERIMENTAL_XDS_MTLS_SPIFFE environment variable. The new bootstrap field will not be read if this env var is unset. This env var guard will be removed when the feature has passed interop tests.
"""