diff --git a/cmd/thv-operator/api/v1beta1/mcpexternalauthconfig_types.go b/cmd/thv-operator/api/v1beta1/mcpexternalauthconfig_types.go
index a2e5ca9d6a..29d677190e 100644
--- a/cmd/thv-operator/api/v1beta1/mcpexternalauthconfig_types.go
+++ b/cmd/thv-operator/api/v1beta1/mcpexternalauthconfig_types.go
@@ -13,6 +13,7 @@ import (
"github.com/stacklok/toolhive/pkg/authserver"
"github.com/stacklok/toolhive/pkg/authserver/oauthparams"
"github.com/stacklok/toolhive/pkg/authserver/server/tokenexchange"
+ "github.com/stacklok/toolhive/pkg/oauthproto"
)
// External auth configuration types
@@ -742,9 +743,6 @@ type SPIFFETrustDomainConfig struct {
// Trust material comes from the declared bundle source (see
// SPIFFETrustDomainConfig's doc comment).
//
-// The CRD does not expose grantTypes. The converter always supplies the
-// RFC 8693 token-exchange grant instead of letting it be configured.
-//
// +kubebuilder:validation:XValidation:rule="self.principalPattern.split('/').all(segment, segment != '.' && segment != '..')",message="principalPattern path must not contain . or .. segments"
// +kubebuilder:validation:XValidation:rule="has(self.resources) && size(self.resources) > 0",message="resources is required"
//
@@ -787,8 +785,9 @@ type SPIFFEClientConfig struct {
// allowlist membership is validated at reconcile time, not admission.
// Shape (a well-formed absolute HTTP(S) URI) is independent of that
// derived allowlist and is validated here. Required, with at least one
- // entry, for every association: token exchange takes exactly one resource
- // per request and grants it as the token audience.
+ // entry, for every association: client_credentials and token exchange each
+ // take exactly one resource per request and grant it as the token
+ // audience.
// +optional
// +kubebuilder:validation:MaxItems=50
// +kubebuilder:validation:items:MinLength=1
@@ -819,6 +818,22 @@ type SPIFFEClientConfig struct {
// +kubebuilder:validation:items:MaxLength=256
// +listType=set
Scopes []string `json:"scopes"`
+
+ // GrantTypes contains the OAuth grants permitted for this association.
+ // It defaults to the token-exchange grant when omitted, which is what the
+ // operator configured before this field existed. List client_credentials
+ // to opt in to the SPIFFE-bound client credentials grant. The list alone
+ // decides which grants the association may use: client authentication does
+ // not confer any grant, and there is no separate per-grant enable switch.
+ // Use urn:ietf:params:oauth:grant-type:token-exchange for RFC 8693 token
+ // exchange.
+ // +optional
+ // +kubebuilder:default={"urn:ietf:params:oauth:grant-type:token-exchange"}
+ // +kubebuilder:validation:MinItems=1
+ // +kubebuilder:validation:MaxItems=2
+ // +kubebuilder:validation:items:Enum={"client_credentials","urn:ietf:params:oauth:grant-type:token-exchange"}
+ // +listType=set
+ GrantTypes []string `json:"grantTypes,omitempty"`
}
// InboundGrantsConfig groups canonical inbound OAuth grant-family configuration.
@@ -926,8 +941,9 @@ type JWTBearerIssuerPolicyConfig struct {
// This type is shared by MCPExternalAuthConfig.Spec.EmbeddedAuthServer and
// VirtualMCPServer.Spec.AuthServerConfig, so the XValidation rules below are
// enforced at admission for both CRDs. CEL only requires the explicit opt-in for
-// delegate clients using an HTTP issuer; the shared Go validator performs the
-// precise loopback-host security check.
+// delegate clients and JWT-SVID SPIFFE client_credentials associations using an
+// HTTP issuer; the shared Go validator performs the precise loopback-host
+// security check.
//
// +kubebuilder:validation:XValidation:rule="(has(self.upstreamProviders) && size(self.upstreamProviders) > 0) || (has(self.delegateClients) && size(self.delegateClients) > 0) || (has(self.trustedIssuers) && self.trustedIssuers.exists(issuer, has(issuer.jwtBearerGrant))) || (has(self.inboundGrants) && (has(self.inboundGrants.tokenExchange) || has(self.inboundGrants.jwtBearer) || (has(self.inboundGrants.spiffeClientAuth) && size(self.inboundGrants.spiffeClientAuth) > 0)))",message="at least one upstream provider or inbound grant family is required"
//
@@ -943,9 +959,9 @@ type JWTBearerIssuerPolicyConfig struct {
// +kubebuilder:validation:XValidation:rule="!has(self.inboundGrants) || !has(self.inboundGrants.spiffeClientAuth) || self.inboundGrants.spiffeClientAuth.all(client, !client.clientId.startsWith('synthetic:'))",message="spiffeClientAuth clientId must not use the reserved synthetic: prefix"
// +kubebuilder:validation:XValidation:rule="!has(self.inboundGrants) || !has(self.inboundGrants.spiffeClientAuth) || self.inboundGrants.spiffeClientAuth.all(client, !client.clientId.matches('^[A-Za-z][A-Za-z0-9+.-]*://.+'))",message="spiffeClientAuth clientId must not be an absolute URL"
//
-// +kubebuilder:validation:XValidation:rule="!(has(self.insecureAllowHTTP) && self.insecureAllowHTTP && ((has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration) || (has(self.delegateClients) && size(self.delegateClients) > 0) || (has(self.inboundGrants) && has(self.inboundGrants.tokenExchange) && has(self.inboundGrants.tokenExchange.delegateClients) && size(self.inboundGrants.tokenExchange.delegateClients) > 0)))",message="insecureAllowHTTP cannot be combined with confidential client registration or delegateClients; client secrets would be issued or used in cleartext over an unauthenticated endpoint"
+// +kubebuilder:validation:XValidation:rule="!(has(self.insecureAllowHTTP) && self.insecureAllowHTTP && ((has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration) || (has(self.delegateClients) && size(self.delegateClients) > 0) || (has(self.inboundGrants) && has(self.inboundGrants.tokenExchange) && has(self.inboundGrants.tokenExchange.delegateClients) && size(self.inboundGrants.tokenExchange.delegateClients) > 0) || (has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth) && self.inboundGrants.spiffeClientAuth.exists(a, 'spiffe_jwt' in a.methods && has(a.grantTypes) && 'client_credentials' in a.grantTypes))))",message="insecureAllowHTTP cannot be combined with confidential client registration, delegateClients or JWT-SVID SPIFFE associations that grant client_credentials; client secrets or JWT-SVIDs would be issued or used in cleartext over an unauthenticated endpoint"
// +kubebuilder:validation:XValidation:rule="(!has(self.forceConfidentialRedirectUris) || size(self.forceConfidentialRedirectUris) == 0) || (has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)",message="forceConfidentialRedirectUris requires allowConfidentialClientRegistration to be true"
-// +kubebuilder:validation:XValidation:rule="!self.issuer.startsWith('http://') || (has(self.insecureAllowConfidentialOverLoopbackHTTP) && self.insecureAllowConfidentialOverLoopbackHTTP) || ((!has(self.allowConfidentialClientRegistration) || !self.allowConfidentialClientRegistration) && (!has(self.delegateClients) || size(self.delegateClients) == 0) && (!has(self.inboundGrants) || !has(self.inboundGrants.tokenExchange) || !has(self.inboundGrants.tokenExchange.delegateClients) || size(self.inboundGrants.tokenExchange.delegateClients) == 0))",message="confidential client registration or delegateClients with an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP to be explicitly enabled; the issuer must still be loopback"
+// +kubebuilder:validation:XValidation:rule="!self.issuer.startsWith('http://') || (has(self.insecureAllowConfidentialOverLoopbackHTTP) && self.insecureAllowConfidentialOverLoopbackHTTP) || ((!has(self.allowConfidentialClientRegistration) || !self.allowConfidentialClientRegistration) && (!has(self.delegateClients) || size(self.delegateClients) == 0) && (!has(self.inboundGrants) || !has(self.inboundGrants.tokenExchange) || !has(self.inboundGrants.tokenExchange.delegateClients) || size(self.inboundGrants.tokenExchange.delegateClients) == 0) && !(has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth) && self.inboundGrants.spiffeClientAuth.exists(a, 'spiffe_jwt' in a.methods && has(a.grantTypes) && 'client_credentials' in a.grantTypes)))",message="confidential client registration, delegateClients or JWT-SVID SPIFFE associations that grant client_credentials with an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP to be explicitly enabled; the issuer must still be loopback"
// +kubebuilder:validation:XValidation:rule="!has(self.inboundGrants) || !has(self.inboundGrants.tokenExchange) || ((!has(self.delegateClients) || size(self.delegateClients) == 0) && (!has(self.trustedIssuers) || !self.trustedIssuers.exists(issuer, has(issuer.expectedAudience) || has(issuer.actorClaim) || has(issuer.allowedActors) || has(issuer.actorMatcher) || has(issuer.allowedDelegateClients) || (has(issuer.allowMayAct) && issuer.allowMayAct))))",message="canonical tokenExchange conflicts with legacy delegateClients or RFC 8693 trusted issuer policy"
// +kubebuilder:validation:XValidation:rule="!has(self.inboundGrants) || !has(self.inboundGrants.jwtBearer) || !has(self.trustedIssuers) || !self.trustedIssuers.exists(issuer, has(issuer.jwtBearerGrant))",message="canonical jwtBearer conflicts with legacy jwtBearerGrant"
// +kubebuilder:validation:XValidation:rule="!has(self.trustedIssuers) || self.trustedIssuers.all(issuer, !has(issuer.name) || self.trustedIssuers.filter(other, has(other.name) && other.name == issuer.name).size() == 1)",message="trustedIssuers must not contain duplicate names"
@@ -1102,8 +1118,10 @@ type EmbeddedAuthServerConfig struct {
//
// One combination is rejected at admission on all three CRDs regardless of the
// above: setting this field alongside confidential client registration or
- // delegate clients, which would issue or use client secrets in cleartext over
- // an unauthenticated endpoint (see the XValidation rule on
+ // delegate clients, or a SPIFFE association that has spiffe_jwt in methods and
+ // client_credentials in grantTypes on the same association, which would issue
+ // or use client secrets or JWT-SVIDs in cleartext over an unauthenticated
+ // endpoint (see the XValidation rule on
// EmbeddedAuthServerConfig).
// +kubebuilder:default=false
// +optional
@@ -1166,9 +1184,12 @@ type EmbeddedAuthServerConfig struct {
AllowPrivateKeyJWTRegistration bool `json:"allowPrivateKeyJWTRegistration,omitempty"`
// InsecureAllowConfidentialOverLoopbackHTTP opts in to confidential
- // Dynamic Client Registration (DCR) and delegate clients when issuer is a
- // plain-HTTP loopback URL (e.g. "http://localhost:8080"). Without this
- // flag, that combination is rejected at reconcile time: a loopback http://
+ // Dynamic Client Registration (DCR), delegate clients and SPIFFE
+ // associations that have spiffe_jwt in methods and client_credentials in
+ // grantTypes on the same association, when issuer is a plain-HTTP loopback
+ // URL (e.g. "http://localhost:8080"). Without this
+ // flag, that combination is rejected at admission, and reconcile additionally
+ // requires the issuer host to be loopback. A loopback http://
// issuer is normally fine for local development since the traffic never
// leaves the machine, but confidential clients send secrets over cleartext.
// Forcing TLS onto every loopback deployment instead would just push
@@ -1403,6 +1424,14 @@ func applyEffectiveJWTBearer(
return nil
}
+// hasConfidentialClients reports whether DCR of confidential clients is
+// enabled, the effective grants include a delegate client, or a SPIFFE
+// association allows the JWT-SVID method and grants client_credentials.
+func (c *EmbeddedAuthServerConfig) hasConfidentialClients(grants effectiveInboundGrants) bool {
+ return c.AllowConfidentialClientRegistration || len(grants.delegateClients) > 0 ||
+ c.hasSPIFFEJWTClientCredentials()
+}
+
// ValidateInboundGrants validates the effective grant projection shared by
// MCPExternalAuthConfig and inline VirtualMCPServer auth configuration.
func (c *EmbeddedAuthServerConfig) ValidateInboundGrants() error {
@@ -1411,7 +1440,7 @@ func (c *EmbeddedAuthServerConfig) ValidateInboundGrants() error {
return err
}
if err := authserver.ValidateConfidentialClientTransport(
- c.AllowConfidentialClientRegistration || len(grants.delegateClients) > 0,
+ c.hasConfidentialClients(grants),
c.InsecureAllowHTTP,
c.Issuer,
c.InsecureAllowConfidentialOverLoopbackHTTP,
@@ -1485,6 +1514,18 @@ func (c *EmbeddedAuthServerConfig) hasSPIFFEMethod(method SPIFFEAuthenticationMe
})
}
+// hasSPIFFEJWTClientCredentials reports whether any single SPIFFE association
+// allows the JWT-SVID method and lists the client_credentials grant.
+func (c *EmbeddedAuthServerConfig) hasSPIFFEJWTClientCredentials() bool {
+ if c.InboundGrants == nil {
+ return false
+ }
+ return slices.ContainsFunc(c.InboundGrants.SPIFFEClientAuth, func(a SPIFFEClientConfig) bool {
+ return slices.Contains(a.Methods, SPIFFEAuthenticationMethodJWT) &&
+ slices.Contains(a.GrantTypes, oauthproto.GrantTypeClientCredentials)
+ })
+}
+
func hasLegacyTokenExchangePolicy(issuer TrustedIssuerConfig) bool {
return issuer.ExpectedAudience != "" || issuer.ActorClaim != "" || len(issuer.AllowedActors) > 0 ||
issuer.ActorMatcher != "" || len(issuer.AllowedDelegateClients) > 0 || issuer.AllowMayAct
diff --git a/cmd/thv-operator/api/v1beta1/mcpexternalauthconfig_types_test.go b/cmd/thv-operator/api/v1beta1/mcpexternalauthconfig_types_test.go
index 90d5dae947..436b183b52 100644
--- a/cmd/thv-operator/api/v1beta1/mcpexternalauthconfig_types_test.go
+++ b/cmd/thv-operator/api/v1beta1/mcpexternalauthconfig_types_test.go
@@ -980,9 +980,10 @@ func TestMCPExternalAuthConfig_validateEmbeddedAuthServer(t *testing.T) {
// admission-time pre-check fabricated a nil
// allowlist/default-scopes set instead of
// deferring to reconcile time.
- Resources: []string{"https://backend.example.com"},
- Audiences: []string{"https://mcp.example.com"},
- Scopes: []string{"custom:scope"},
+ Resources: []string{"https://backend.example.com"},
+ Audiences: []string{"https://mcp.example.com"},
+ Scopes: []string{"custom:scope"},
+ GrantTypes: []string{"urn:ietf:params:oauth:grant-type:token-exchange"},
}},
},
},
@@ -1352,11 +1353,13 @@ func mustEmbeddedAuthServerConfigWithPrincipalPatterns(first, second string) *MC
TrustDomainRef: "example", PrincipalPattern: first, ClientID: "spiffe-client-1",
Methods: []SPIFFEAuthenticationMethod{SPIFFEAuthenticationMethodX509},
Audiences: []string{"https://mcp.example.com"}, Resources: []string{"https://mcp.example.com"}, Scopes: []string{"openid"},
+ GrantTypes: []string{"urn:ietf:params:oauth:grant-type:token-exchange"},
},
{
TrustDomainRef: "example", PrincipalPattern: second, ClientID: "spiffe-client-2",
Methods: []SPIFFEAuthenticationMethod{SPIFFEAuthenticationMethodX509},
Audiences: []string{"https://mcp.example.com"}, Resources: []string{"https://mcp.example.com"}, Scopes: []string{"openid"},
+ GrantTypes: []string{"urn:ietf:params:oauth:grant-type:token-exchange"},
},
},
},
@@ -1398,7 +1401,8 @@ func mustEmbeddedAuthServerConfigWithResource(resource string) *MCPExternalAuthC
ClientID: "spiffe-client",
Methods: []SPIFFEAuthenticationMethod{SPIFFEAuthenticationMethodX509},
Audiences: []string{"https://mcp.example.com"}, Scopes: []string{"openid"},
- Resources: []string{resource},
+ Resources: []string{resource},
+ GrantTypes: []string{"urn:ietf:params:oauth:grant-type:token-exchange"},
}},
},
},
@@ -1465,6 +1469,7 @@ func TestMCPExternalAuthConfig_ZeroUpstreamAlternatives(t *testing.T) {
ClientID: "spiffe-client",
Methods: []SPIFFEAuthenticationMethod{SPIFFEAuthenticationMethodX509},
Audiences: []string{"https://mcp.example.com"}, Resources: []string{"https://mcp.example.com"}, Scopes: []string{"openid"},
+ GrantTypes: []string{"urn:ietf:params:oauth:grant-type:token-exchange"},
}},
},
},
@@ -2114,30 +2119,71 @@ func TestEmbeddedAuthServerConfig_ValidateInboundGrants_ConfidentialClientTransp
SPIFFEClientAuth: []SPIFFEClientConfig{{
TrustDomainRef: "example", PrincipalPattern: "spiffe://example.org/ns/default/agent",
ClientID: "spiffe-client", Methods: []SPIFFEAuthenticationMethod{method},
- Resources: []string{"https://mcp.example.com"}, Scopes: []string{"openid"},
+ Resources: []string{"https://mcp.example.com"},
+ Scopes: []string{"openid"}, GrantTypes: []string{"client_credentials"},
}},
},
}
mutate(&config)
return config
}
+ splitSPIFFEMethodAndGrant := func(c *EmbeddedAuthServerConfig) {
+ c.SPIFFETrustDomains[0].Methods = []SPIFFEAuthenticationMethod{SPIFFEAuthenticationMethodJWT, SPIFFEAuthenticationMethodX509}
+ first := &c.InboundGrants.SPIFFEClientAuth[0]
+ first.GrantTypes = []string{"urn:ietf:params:oauth:grant-type:token-exchange"}
+ second := *first
+ second.PrincipalPattern = "spiffe://example.org/ns/default/other"
+ second.ClientID = "spiffe-client-x509"
+ second.Methods = []SPIFFEAuthenticationMethod{SPIFFEAuthenticationMethodX509}
+ second.GrantTypes = []string{"client_credentials"}
+ c.InboundGrants.SPIFFEClientAuth = append(c.InboundGrants.SPIFFEClientAuth, second)
+ }
tests := []struct {
name string
config EmbeddedAuthServerConfig
expectErr bool
}{
{
- name: "SPIFFE JWT association is admitted with insecure HTTP",
+ name: "SPIFFE JWT client_credentials association rejects insecure HTTP",
+ config: spiffeConfig(SPIFFEAuthenticationMethodJWT, func(c *EmbeddedAuthServerConfig) {
+ c.InsecureAllowHTTP = true
+ }),
+ expectErr: true,
+ },
+ {
+ name: "SPIFFE JWT client_credentials association rejects HTTP loopback without explicit opt in",
+ config: spiffeConfig(SPIFFEAuthenticationMethodJWT, func(*EmbeddedAuthServerConfig) {}),
+ expectErr: true,
+ },
+ {
+ name: "SPIFFE JWT client_credentials association allows HTTP loopback with explicit opt in",
+ config: spiffeConfig(SPIFFEAuthenticationMethodJWT, func(c *EmbeddedAuthServerConfig) {
+ c.InsecureAllowConfidentialOverLoopbackHTTP = true
+ }),
+ },
+ {
+ name: "SPIFFE JWT token-exchange-only association is admitted with insecure HTTP",
config: spiffeConfig(SPIFFEAuthenticationMethodJWT, func(c *EmbeddedAuthServerConfig) {
c.InsecureAllowHTTP = true
+ c.InboundGrants.SPIFFEClientAuth[0].GrantTypes = []string{"urn:ietf:params:oauth:grant-type:token-exchange"}
}),
},
{
- name: "SPIFFE JWT association is admitted on HTTP loopback without explicit opt in",
- config: spiffeConfig(SPIFFEAuthenticationMethodJWT, func(*EmbeddedAuthServerConfig) {}),
+ name: "SPIFFE JWT token-exchange-only association is admitted on HTTP loopback without explicit opt in",
+ config: spiffeConfig(SPIFFEAuthenticationMethodJWT, func(c *EmbeddedAuthServerConfig) {
+ c.InboundGrants.SPIFFEClientAuth[0].GrantTypes = []string{"urn:ietf:params:oauth:grant-type:token-exchange"}
+ }),
+ },
+ {
+ name: "SPIFFE JWT token exchange plus X.509 client_credentials on separate associations is admitted with insecure HTTP",
+ config: spiffeConfig(SPIFFEAuthenticationMethodJWT, func(c *EmbeddedAuthServerConfig) {
+ c.InsecureAllowHTTP = true
+ c.Issuer = "https://auth.example.com"
+ splitSPIFFEMethodAndGrant(c)
+ }),
},
{
- name: "SPIFFE X.509-only association is unaffected by insecure HTTP",
+ name: "SPIFFE X.509 client_credentials association is unaffected by insecure HTTP",
config: spiffeConfig(SPIFFEAuthenticationMethodX509, func(c *EmbeddedAuthServerConfig) {
c.InsecureAllowHTTP = true
c.Issuer = "https://auth.example.com"
@@ -2401,6 +2447,7 @@ func TestEmbeddedAuthServerConfig_ValidateTLSListener(t *testing.T) {
return &InboundGrantsConfig{SPIFFEClientAuth: []SPIFFEClientConfig{{
TrustDomainRef: "example", PrincipalPattern: "spiffe://example.org/ns/default/agent",
ClientID: "spiffe-client", Methods: []SPIFFEAuthenticationMethod{method},
+ GrantTypes: []string{"client_credentials"},
}}}
}
trustDomains := []SPIFFETrustDomainConfig{{
diff --git a/cmd/thv-operator/api/v1beta1/zz_generated.deepcopy.go b/cmd/thv-operator/api/v1beta1/zz_generated.deepcopy.go
index 4cf7177dc6..f3d575a629 100644
--- a/cmd/thv-operator/api/v1beta1/zz_generated.deepcopy.go
+++ b/cmd/thv-operator/api/v1beta1/zz_generated.deepcopy.go
@@ -3047,6 +3047,11 @@ func (in *SPIFFEClientConfig) DeepCopyInto(out *SPIFFEClientConfig) {
*out = make([]string, len(*in))
copy(*out, *in)
}
+ if in.GrantTypes != nil {
+ in, out := &in.GrantTypes, &out.GrantTypes
+ *out = make([]string, len(*in))
+ copy(*out, *in)
+ }
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SPIFFEClientConfig.
diff --git a/cmd/thv-operator/controllers/virtualmcpserver_controller_test.go b/cmd/thv-operator/controllers/virtualmcpserver_controller_test.go
index 863999883f..1b18c0697e 100644
--- a/cmd/thv-operator/controllers/virtualmcpserver_controller_test.go
+++ b/cmd/thv-operator/controllers/virtualmcpserver_controller_test.go
@@ -4820,6 +4820,7 @@ func TestVirtualMCPServerValidateAuthServerConfig_TLSListener(t *testing.T) {
Audiences: []string{"https://mcp.example.com"},
Resources: []string{"https://mcp.example.com"},
Scopes: []string{"openid"},
+ GrantTypes: []string{"urn:ietf:params:oauth:grant-type:token-exchange"},
}}}
tests := []struct {
@@ -4959,6 +4960,7 @@ func TestVirtualMCPServerValidateAuthServerConfig_ZeroUpstreamAlternatives(t *te
ClientID: "spiffe-client",
Methods: []mcpv1beta1.SPIFFEAuthenticationMethod{mcpv1beta1.SPIFFEAuthenticationMethodX509},
Resources: []string{"https://mcp.example.com"}, Scopes: []string{"openid"},
+ GrantTypes: []string{"urn:ietf:params:oauth:grant-type:token-exchange"},
}},
},
},
@@ -5031,46 +5033,67 @@ func TestVirtualMCPServerValidateAuthServerConfig_CanonicalTrustedIssuer(t *test
assert.Equal(t, metav1.ConditionFalse, condition.Status)
}
-func TestVirtualMCPServerValidateAuthServerConfig_SPIFFEAssociationWithoutResources(t *testing.T) {
+func TestVirtualMCPServerValidateAuthServerConfig_SPIFFEAssociationRequiresResources(t *testing.T) {
t.Parallel()
- vmcp := v1beta1test.NewVirtualMCPServer(testVmcpName, "default",
- v1beta1test.WithVMCPGroupRef("test-group"),
- v1beta1test.WithVMCPAuthServerConfig(&mcpv1beta1.EmbeddedAuthServerConfig{
- Issuer: "https://auth.example.com",
- TLSListener: &mcpv1beta1.TLSListenerConfig{
- CertificateSecretRef: &mcpv1beta1.SecretKeyRef{Name: "listener-tls", Key: "certificate"},
- PrivateKeySecretRef: &mcpv1beta1.SecretKeyRef{Name: "listener-tls", Key: "private-key"},
- },
- SPIFFETrustDomains: []mcpv1beta1.SPIFFETrustDomainConfig{{
- Name: "example", TrustDomain: "example.org",
- Methods: []mcpv1beta1.SPIFFEAuthenticationMethod{mcpv1beta1.SPIFFEAuthenticationMethodX509},
- BundleSource: mcpv1beta1.SPIFFEBundleSourceConfig{
- Type: mcpv1beta1.SPIFFEBundleSourceTypeFile,
- File: &mcpv1beta1.SPIFFEFileBundleSourceConfig{ConfigMapName: "spire-bundle", ConfigMapKey: "bundle.json"},
- },
- }},
- InboundGrants: &mcpv1beta1.InboundGrantsConfig{
- SPIFFEClientAuth: []mcpv1beta1.SPIFFEClientConfig{{
- TrustDomainRef: "example", PrincipalPattern: "spiffe://example.org/ns/default/agent",
- ClientID: "spiffe-client",
- Methods: []mcpv1beta1.SPIFFEAuthenticationMethod{mcpv1beta1.SPIFFEAuthenticationMethodX509},
- Resources: nil, Scopes: []string{"openid"},
- }},
- },
- }),
- )
- statusManager := virtualmcpserverstatus.NewStatusManager(vmcp)
+ tests := []struct {
+ name string
+ resources []string
+ grantTypes []string
+ wantErr string
+ }{
+ {
+ name: "missing resources",
+ grantTypes: []string{"urn:ietf:params:oauth:grant-type:token-exchange"},
+ wantErr: "inboundGrants.spiffeClientAuth[0].resources is required",
+ },
+ }
- err := (&VirtualMCPServerReconciler{}).validateAuthServerConfig(vmcp, statusManager)
- statusManager.UpdateStatus(t.Context(), &vmcp.Status)
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ t.Parallel()
- require.ErrorContains(t, err, "inboundGrants.spiffeClientAuth[0].resources is required")
- condition := findCondition(vmcp.Status.Conditions, mcpv1beta1.ConditionTypeAuthServerConfigValidated)
- require.NotNil(t, condition)
- assert.Equal(t, metav1.ConditionFalse, condition.Status)
- assert.Equal(t, mcpv1beta1.ConditionReasonAuthServerConfigInvalid, condition.Reason)
- assert.Contains(t, condition.Message, "inboundGrants.spiffeClientAuth[0].resources is required")
+ vmcp := v1beta1test.NewVirtualMCPServer(testVmcpName, "default",
+ v1beta1test.WithVMCPGroupRef("test-group"),
+ v1beta1test.WithVMCPAuthServerConfig(&mcpv1beta1.EmbeddedAuthServerConfig{
+ Issuer: "https://auth.example.com",
+ TLSListener: &mcpv1beta1.TLSListenerConfig{
+ CertificateSecretRef: &mcpv1beta1.SecretKeyRef{Name: "listener-tls", Key: "certificate"},
+ PrivateKeySecretRef: &mcpv1beta1.SecretKeyRef{Name: "listener-tls", Key: "private-key"},
+ },
+ SPIFFETrustDomains: []mcpv1beta1.SPIFFETrustDomainConfig{{
+ Name: "example", TrustDomain: "example.org",
+ Methods: []mcpv1beta1.SPIFFEAuthenticationMethod{mcpv1beta1.SPIFFEAuthenticationMethodX509},
+ BundleSource: mcpv1beta1.SPIFFEBundleSourceConfig{
+ Type: mcpv1beta1.SPIFFEBundleSourceTypeFile,
+ File: &mcpv1beta1.SPIFFEFileBundleSourceConfig{ConfigMapName: "spire-bundle", ConfigMapKey: "bundle.json"},
+ },
+ }},
+ InboundGrants: &mcpv1beta1.InboundGrantsConfig{
+ SPIFFEClientAuth: []mcpv1beta1.SPIFFEClientConfig{{
+ TrustDomainRef: "example", PrincipalPattern: "spiffe://example.org/ns/default/agent",
+ ClientID: "spiffe-client",
+ Methods: []mcpv1beta1.SPIFFEAuthenticationMethod{mcpv1beta1.SPIFFEAuthenticationMethodX509},
+ Resources: tt.resources,
+ Scopes: []string{"openid"},
+ GrantTypes: tt.grantTypes,
+ }},
+ },
+ }),
+ )
+ statusManager := virtualmcpserverstatus.NewStatusManager(vmcp)
+
+ err := (&VirtualMCPServerReconciler{}).validateAuthServerConfig(vmcp, statusManager)
+ statusManager.UpdateStatus(t.Context(), &vmcp.Status)
+
+ require.ErrorContains(t, err, tt.wantErr)
+ condition := findCondition(vmcp.Status.Conditions, mcpv1beta1.ConditionTypeAuthServerConfigValidated)
+ require.NotNil(t, condition)
+ assert.Equal(t, metav1.ConditionFalse, condition.Status)
+ assert.Equal(t, mcpv1beta1.ConditionReasonAuthServerConfigInvalid, condition.Reason)
+ assert.Contains(t, condition.Message, tt.wantErr)
+ })
+ }
}
func TestVirtualMCPServerValidateAuthServerConfig_TrustedIssuerEndpointRecovery(t *testing.T) {
diff --git a/cmd/thv-operator/pkg/controllerutil/authserver.go b/cmd/thv-operator/pkg/controllerutil/authserver.go
index 1f048fcac6..e9c4ff5d31 100644
--- a/cmd/thv-operator/pkg/controllerutil/authserver.go
+++ b/cmd/thv-operator/pkg/controllerutil/authserver.go
@@ -388,9 +388,7 @@ func buildSPIFFEBundleSourceRunConfig(
}
// buildSPIFFEClientAuthRunConfigs converts CRD SPIFFEClientConfig entries to
-// authserver.SPIFFEClientAuthRunConfig. The CRD does not expose grantTypes,
-// so the RFC 8693 token-exchange grant is always supplied here rather than
-// configured.
+// authserver.SPIFFEClientAuthRunConfig.
func buildSPIFFEClientAuthRunConfigs(
clients []mcpv1beta1.SPIFFEClientConfig,
) []authserver.SPIFFEClientAuthRunConfig {
@@ -410,12 +408,25 @@ func buildSPIFFEClientAuthRunConfigs(
Resources: append([]string(nil), spiffeClient.Resources...),
Audiences: deprecatedAudiences,
Scopes: append([]string(nil), spiffeClient.Scopes...),
- GrantTypes: []string{oauthproto.GrantTypeTokenExchange},
+ GrantTypes: spiffeGrantTypesOrDefault(spiffeClient.GrantTypes),
}
}
return configs
}
+// spiffeGrantTypesOrDefault copies grantTypes, or returns the token-exchange
+// grant when it is empty. The CRD default normally fills it in, but an object
+// served by an older CRD schema (the operator chart upgraded without the CRD
+// chart) or built without the API server has none. Token exchange is what the
+// operator configured before the field existed, so this mirrors the CRD
+// default instead of failing the reconcile.
+func spiffeGrantTypesOrDefault(grantTypes []string) []string {
+ if len(grantTypes) == 0 {
+ return []string{oauthproto.GrantTypeTokenExchange}
+ }
+ return append([]string(nil), grantTypes...)
+}
+
// EmbeddedAuthServerConfigName returns the config name that should be used for
// embedded auth server volume/env generation, or empty string if neither ref applies.
// AuthServerRef takes precedence; externalAuthConfigRef is used as a fallback.
diff --git a/cmd/thv-operator/pkg/controllerutil/authserver_listener_tls_test.go b/cmd/thv-operator/pkg/controllerutil/authserver_listener_tls_test.go
index bc1c02696d..d458135f70 100644
--- a/cmd/thv-operator/pkg/controllerutil/authserver_listener_tls_test.go
+++ b/cmd/thv-operator/pkg/controllerutil/authserver_listener_tls_test.go
@@ -116,6 +116,7 @@ func TestBuildAuthServerRunConfigTLSListener(t *testing.T) {
Audiences: []string{"https://mcp.example.com"},
Resources: []string{"https://mcp.example.com"},
Scopes: []string{"openid"},
+ GrantTypes: []string{"client_credentials"},
}}}
}
diff --git a/cmd/thv-operator/pkg/controllerutil/authserver_test.go b/cmd/thv-operator/pkg/controllerutil/authserver_test.go
index 6c30680b73..2a6de5c8a6 100644
--- a/cmd/thv-operator/pkg/controllerutil/authserver_test.go
+++ b/cmd/thv-operator/pkg/controllerutil/authserver_test.go
@@ -8,6 +8,7 @@ import (
"encoding/json"
stderrors "errors"
"fmt"
+ "slices"
"strings"
"testing"
"time"
@@ -3696,34 +3697,94 @@ func TestBuildSPIFFETrustDomainRunConfigs(t *testing.T) {
func TestBuildSPIFFEClientAuthRunConfigs(t *testing.T) {
t.Parallel()
- audiences := []string{"https://mcp.example.com"}
- scopes := []string{"openid"}
- resources := []string{"https://backend.example.com"}
- configs := buildSPIFFEClientAuthRunConfigs([]mcpv1beta1.SPIFFEClientConfig{{
- TrustDomainRef: "example",
- PrincipalPattern: "spiffe://example.org/ns/default/agent",
- ClientID: "spiffe-client",
- Methods: []mcpv1beta1.SPIFFEAuthenticationMethod{mcpv1beta1.SPIFFEAuthenticationMethodX509},
- Resources: resources,
- Audiences: audiences, //nolint:staticcheck // Exercises the deprecated pass-through.
- Scopes: scopes,
- }})
-
- require.Len(t, configs, 1)
- assert.Equal(t, "example", configs[0].TrustDomainRef)
- assert.Equal(t, "spiffe://example.org/ns/default/agent", configs[0].PrincipalPattern)
- assert.Equal(t, "spiffe-client", configs[0].ClientID)
- assert.Equal(t, []authserver.SPIFFEAuthenticationMethod{authserver.SPIFFEAuthenticationMethodX509}, configs[0].Methods)
- assert.Equal(t, []string{"https://backend.example.com"}, configs[0].Resources)
- assert.Equal(t, []string{"https://mcp.example.com"}, configs[0].Audiences)
- assert.Equal(t, []string{"openid"}, configs[0].Scopes)
- // GrantTypes is not a CRD field; the converter always supplies exactly
- // the RFC 8693 token-exchange grant.
- assert.Equal(t, []string{oauthproto.GrantTypeTokenExchange}, configs[0].GrantTypes)
+ const (
+ tokenExchange = "urn:ietf:params:oauth:grant-type:token-exchange"
+ clientCredentials = "client_credentials"
+ )
+ tests := []struct {
+ name string
+ grantTypes []string
+ resources []string
+ audiences []string
+ wantGrants []string
+ }{
+ {
+ name: "token exchange only association",
+ grantTypes: []string{tokenExchange},
+ resources: []string{"https://backend.example.com"},
+ audiences: []string{"https://mcp.example.com"},
+ wantGrants: []string{oauthproto.GrantTypeTokenExchange},
+ },
+ {
+ name: "client credentials only association",
+ grantTypes: []string{clientCredentials},
+ resources: []string{"https://backend.example.com"},
+ audiences: []string{"https://mcp.example.com"},
+ wantGrants: []string{oauthproto.GrantTypeClientCredentials},
+ },
+ {
+ name: "association with both grants",
+ grantTypes: []string{tokenExchange, clientCredentials},
+ resources: []string{"https://backend.example.com"},
+ audiences: []string{"https://mcp.example.com"},
+ wantGrants: []string{oauthproto.GrantTypeTokenExchange, oauthproto.GrantTypeClientCredentials},
+ },
+ {
+ name: "nil grantTypes falls back to token exchange",
+ grantTypes: nil,
+ resources: []string{"https://backend.example.com"},
+ audiences: []string{"https://mcp.example.com"},
+ wantGrants: []string{oauthproto.GrantTypeTokenExchange},
+ },
+ {
+ name: "empty grantTypes falls back to token exchange",
+ grantTypes: []string{},
+ resources: []string{"https://backend.example.com"},
+ audiences: []string{"https://mcp.example.com"},
+ wantGrants: []string{oauthproto.GrantTypeTokenExchange},
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ t.Parallel()
- // The runtime type must not retain the CRD object's backing slices.
- audiences[0] = "https://mutated.example.com"
- assert.Equal(t, "https://mcp.example.com", configs[0].Audiences[0])
+ scopes := []string{"openid"}
+ source := mcpv1beta1.SPIFFEClientConfig{
+ TrustDomainRef: "example",
+ PrincipalPattern: "spiffe://example.org/ns/default/agent",
+ ClientID: "spiffe-client",
+ Methods: []mcpv1beta1.SPIFFEAuthenticationMethod{mcpv1beta1.SPIFFEAuthenticationMethodX509},
+ Resources: slices.Clone(tt.resources),
+ Audiences: tt.audiences, //nolint:staticcheck // Exercises the deprecated pass-through.
+ Scopes: scopes,
+ GrantTypes: tt.grantTypes,
+ }
+ configs := buildSPIFFEClientAuthRunConfigs([]mcpv1beta1.SPIFFEClientConfig{source})
+
+ require.Len(t, configs, 1)
+ got := configs[0]
+ assert.Equal(t, "example", got.TrustDomainRef)
+ assert.Equal(t, "spiffe://example.org/ns/default/agent", got.PrincipalPattern)
+ assert.Equal(t, "spiffe-client", got.ClientID)
+ assert.Equal(t, []authserver.SPIFFEAuthenticationMethod{authserver.SPIFFEAuthenticationMethodX509}, got.Methods)
+ assert.Equal(t, tt.wantGrants, got.GrantTypes)
+ assert.ElementsMatch(t, tt.resources, got.Resources)
+ assert.Equal(t, tt.audiences, got.Audiences)
+ assert.Equal(t, []string{"openid"}, got.Scopes)
+
+ // The runtime type must not retain the CRD object's backing slices.
+ if len(source.GrantTypes) > 0 {
+ source.GrantTypes[0] = "mutated"
+ }
+ scopes[0] = "mutated"
+ source.Audiences[0] = "https://mutated.example.com" //nolint:staticcheck // Exercises the deprecated pass-through.
+ source.Resources[0] = "https://mutated.example.com"
+ assert.Equal(t, tt.wantGrants, got.GrantTypes)
+ assert.ElementsMatch(t, tt.resources, got.Resources)
+ assert.Equal(t, []string{"openid"}, got.Scopes)
+ assert.NotEqual(t, "https://mutated.example.com", got.Audiences[0])
+ })
+ }
}
// TestBuildAuthServerRunConfigRejectsUnsupportedSPIFFEBundleSource covers the
@@ -3770,6 +3831,7 @@ func TestBuildAuthServerRunConfigRejectsUnsupportedSPIFFEBundleSource(t *testing
Audiences: []string{"https://mcp.example.com"},
Resources: []string{"https://mcp.example.com"},
Scopes: []string{"openid"},
+ GrantTypes: []string{"urn:ietf:params:oauth:grant-type:token-exchange"},
}},
},
}, []string{"https://mcp.example.com"}, []string{"openid"}, "https://mcp.example.com")
@@ -3821,7 +3883,8 @@ func TestBuildAuthServerRunConfigSPIFFEResourcesAndScopesValidateOnceDerivedValu
// A custom, non-default scope: rejected by
// registration.DefaultScopes but valid once the real
// ScopesSupported below is consulted.
- Scopes: []string{"custom:scope"},
+ Scopes: []string{"custom:scope"},
+ GrantTypes: []string{"urn:ietf:params:oauth:grant-type:token-exchange"},
}},
},
}
diff --git a/cmd/thv-operator/test-integration/mcp-external-auth/confidential_client_transport_cel_test.go b/cmd/thv-operator/test-integration/mcp-external-auth/confidential_client_transport_cel_test.go
index 4692406951..13782c0612 100644
--- a/cmd/thv-operator/test-integration/mcp-external-auth/confidential_client_transport_cel_test.go
+++ b/cmd/thv-operator/test-integration/mcp-external-auth/confidential_client_transport_cel_test.go
@@ -101,7 +101,7 @@ var _ = Describe("EmbeddedAuthServerConfig confidential-client-transport CEL val
allowConfidential: true,
insecureHTTP: true,
shouldAdmit: false,
- expectedMessage: "insecureAllowHTTP cannot be combined with confidential client registration or delegateClients",
+ expectedMessage: "insecureAllowHTTP cannot be combined with confidential client registration, delegateClients or JWT-SVID SPIFFE associations that grant client_credentials",
},
{
name: "allowPrivateKeyJWTRegistration with insecureAllowHTTP is admitted (no secret to protect)",
@@ -120,7 +120,7 @@ var _ = Describe("EmbeddedAuthServerConfig confidential-client-transport CEL val
delegateClient: true,
insecureHTTP: true,
shouldAdmit: false,
- expectedMessage: "insecureAllowHTTP cannot be combined with confidential client registration or delegateClients",
+ expectedMessage: "insecureAllowHTTP cannot be combined with confidential client registration, delegateClients or JWT-SVID SPIFFE associations that grant client_credentials",
},
{
name: "canonical delegate clients with insecureAllowHTTP set",
@@ -128,7 +128,7 @@ var _ = Describe("EmbeddedAuthServerConfig confidential-client-transport CEL val
canonicalDelegateClient: true,
insecureHTTP: true,
shouldAdmit: false,
- expectedMessage: "insecureAllowHTTP cannot be combined with confidential client registration or delegateClients",
+ expectedMessage: "insecureAllowHTTP cannot be combined with confidential client registration, delegateClients or JWT-SVID SPIFFE associations that grant client_credentials",
},
{
name: "legacy delegate clients with insecureAllowHTTP and HTTPS issuer",
@@ -136,7 +136,7 @@ var _ = Describe("EmbeddedAuthServerConfig confidential-client-transport CEL val
insecureHTTP: true,
httpsIssuer: true,
shouldAdmit: false,
- expectedMessage: "insecureAllowHTTP cannot be combined with confidential client registration or delegateClients",
+ expectedMessage: "insecureAllowHTTP cannot be combined with confidential client registration, delegateClients or JWT-SVID SPIFFE associations that grant client_credentials",
},
{
name: "canonical delegate clients with insecureAllowHTTP and HTTPS issuer",
@@ -145,14 +145,14 @@ var _ = Describe("EmbeddedAuthServerConfig confidential-client-transport CEL val
insecureHTTP: true,
httpsIssuer: true,
shouldAdmit: false,
- expectedMessage: "insecureAllowHTTP cannot be combined with confidential client registration or delegateClients",
+ expectedMessage: "insecureAllowHTTP cannot be combined with confidential client registration, delegateClients or JWT-SVID SPIFFE associations that grant client_credentials",
},
{
name: "delegate clients with loopback HTTP issuer without opt-in",
delegateClient: true,
loopbackHTTP: true,
shouldAdmit: false,
- expectedMessage: "confidential client registration or delegateClients with an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP",
+ expectedMessage: "confidential client registration, delegateClients or JWT-SVID SPIFFE associations that grant client_credentials with an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP",
},
{
name: "canonical delegate clients with loopback HTTP issuer without opt-in",
@@ -160,14 +160,14 @@ var _ = Describe("EmbeddedAuthServerConfig confidential-client-transport CEL val
canonicalDelegateClient: true,
loopbackHTTP: true,
shouldAdmit: false,
- expectedMessage: "confidential client registration or delegateClients with an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP",
+ expectedMessage: "confidential client registration, delegateClients or JWT-SVID SPIFFE associations that grant client_credentials with an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP",
},
{
name: "confidential registration with loopback HTTP issuer without opt-in",
allowConfidential: true,
loopbackHTTP: true,
shouldAdmit: false,
- expectedMessage: "confidential client registration or delegateClients with an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP",
+ expectedMessage: "confidential client registration, delegateClients or JWT-SVID SPIFFE associations that grant client_credentials with an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP",
},
{
name: "confidential registration with opted-in loopback HTTP issuer",
@@ -260,6 +260,6 @@ var _ = Describe("EmbeddedAuthServerConfig confidential-client-transport CEL val
err := k8sClient.Create(ctx, vmcp)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring(
- "confidential client registration or delegateClients with an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP"))
+ "confidential client registration, delegateClients or JWT-SVID SPIFFE associations that grant client_credentials with an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP"))
})
})
diff --git a/cmd/thv-operator/test-integration/mcp-external-auth/spiffe_cel_test.go b/cmd/thv-operator/test-integration/mcp-external-auth/spiffe_cel_test.go
index 74a85366d5..5be3c144b2 100644
--- a/cmd/thv-operator/test-integration/mcp-external-auth/spiffe_cel_test.go
+++ b/cmd/thv-operator/test-integration/mcp-external-auth/spiffe_cel_test.go
@@ -11,6 +11,7 @@ import (
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+ "k8s.io/apimachinery/pkg/types"
mcpv1beta1 "github.com/stacklok/toolhive/cmd/thv-operator/api/v1beta1"
)
@@ -72,6 +73,7 @@ var _ = Describe("MCPExternalAuthConfig SPIFFE CEL validation", func() {
TrustDomainRef: "example", PrincipalPattern: principalPattern, ClientID: "spiffe-client",
Methods: []mcpv1beta1.SPIFFEAuthenticationMethod{mcpv1beta1.SPIFFEAuthenticationMethodX509},
Audiences: []string{"https://mcp.example.com"}, Resources: []string{"https://mcp.example.com"}, Scopes: []string{"openid"},
+ GrantTypes: []string{"urn:ietf:params:oauth:grant-type:token-exchange"},
}},
}
}
@@ -103,6 +105,34 @@ var _ = Describe("MCPExternalAuthConfig SPIFFE CEL validation", func() {
}
}
+ jwtClientCredentials := func(extra func(*mcpv1beta1.EmbeddedAuthServerConfig)) func(*mcpv1beta1.EmbeddedAuthServerConfig) {
+ return func(config *mcpv1beta1.EmbeddedAuthServerConfig) {
+ config.SPIFFETrustDomains[0].Methods = []mcpv1beta1.SPIFFEAuthenticationMethod{mcpv1beta1.SPIFFEAuthenticationMethodJWT}
+ association := &config.InboundGrants.SPIFFEClientAuth[0]
+ association.Methods = []mcpv1beta1.SPIFFEAuthenticationMethod{mcpv1beta1.SPIFFEAuthenticationMethodJWT}
+ association.GrantTypes = []string{"client_credentials"}
+ extra(config)
+ }
+ }
+
+ jwtTokenExchangePlusX509ClientCredentials := func(extra func(*mcpv1beta1.EmbeddedAuthServerConfig)) func(*mcpv1beta1.EmbeddedAuthServerConfig) {
+ return func(config *mcpv1beta1.EmbeddedAuthServerConfig) {
+ config.SPIFFETrustDomains[0].Methods = []mcpv1beta1.SPIFFEAuthenticationMethod{
+ mcpv1beta1.SPIFFEAuthenticationMethodJWT, mcpv1beta1.SPIFFEAuthenticationMethodX509,
+ }
+ first := &config.InboundGrants.SPIFFEClientAuth[0]
+ first.Methods = []mcpv1beta1.SPIFFEAuthenticationMethod{mcpv1beta1.SPIFFEAuthenticationMethodJWT}
+ first.GrantTypes = []string{"urn:ietf:params:oauth:grant-type:token-exchange"}
+ second := *first
+ second.PrincipalPattern = "spiffe://example.org/ns/default/other"
+ second.ClientID = "spiffe-client-x509"
+ second.Methods = []mcpv1beta1.SPIFFEAuthenticationMethod{mcpv1beta1.SPIFFEAuthenticationMethodX509}
+ second.GrantTypes = []string{"client_credentials"}
+ config.InboundGrants.SPIFFEClientAuth = append(config.InboundGrants.SPIFFEClientAuth, second)
+ extra(config)
+ }
+ }
+
cases := []validationCase{
{name: "trust domains without clients", trustDomains: true, errMatch: "must be configured together"},
{
@@ -240,7 +270,30 @@ var _ = Describe("MCPExternalAuthConfig SPIFFE CEL validation", func() {
},
},
{
- name: "JWT-SVID association with insecureAllowHTTP is admitted", trustDomains: true, clients: true,
+ name: "unknown grant type is rejected", trustDomains: true, clients: true,
+ principal: "spiffe://example.org/ns/default/agent", errMatch: "grantTypes",
+ mutate: func(config *mcpv1beta1.EmbeddedAuthServerConfig) {
+ config.InboundGrants.SPIFFEClientAuth[0].GrantTypes = []string{"authorization_code"}
+ },
+ },
+ {
+ name: "duplicate grant type is rejected", trustDomains: true, clients: true,
+ principal: "spiffe://example.org/ns/default/agent", errMatch: "grantTypes",
+ mutate: func(config *mcpv1beta1.EmbeddedAuthServerConfig) {
+ config.InboundGrants.SPIFFEClientAuth[0].GrantTypes = []string{"client_credentials", "client_credentials"}
+ },
+ },
+ {
+ name: "both grants are admitted", trustDomains: true, clients: true,
+ principal: "spiffe://example.org/ns/default/agent", shouldAdmit: true,
+ mutate: func(config *mcpv1beta1.EmbeddedAuthServerConfig) {
+ config.InboundGrants.SPIFFEClientAuth[0].GrantTypes = []string{
+ "client_credentials", "urn:ietf:params:oauth:grant-type:token-exchange",
+ }
+ },
+ },
+ {
+ name: "JWT-SVID token-exchange-only association with insecureAllowHTTP is admitted", trustDomains: true, clients: true,
principal: "spiffe://example.org/ns/default/agent", shouldAdmit: true,
mutate: func(config *mcpv1beta1.EmbeddedAuthServerConfig) {
config.InsecureAllowHTTP = true
@@ -248,6 +301,54 @@ var _ = Describe("MCPExternalAuthConfig SPIFFE CEL validation", func() {
config.InboundGrants.SPIFFEClientAuth[0].Methods = []mcpv1beta1.SPIFFEAuthenticationMethod{mcpv1beta1.SPIFFEAuthenticationMethodJWT}
},
},
+ {
+ name: "JWT-SVID client_credentials association with insecureAllowHTTP is rejected", trustDomains: true, clients: true,
+ principal: "spiffe://example.org/ns/default/agent", errMatch: "JWT-SVID SPIFFE associations that grant client_credentials",
+ mutate: jwtClientCredentials(func(config *mcpv1beta1.EmbeddedAuthServerConfig) {
+ config.InsecureAllowHTTP = true
+ }),
+ },
+ {
+ name: "JWT-SVID client_credentials association with an http loopback issuer is rejected without the loopback opt-in",
+ trustDomains: true, clients: true,
+ principal: "spiffe://example.org/ns/default/agent", errMatch: "JWT-SVID SPIFFE associations that grant client_credentials",
+ mutate: jwtClientCredentials(func(config *mcpv1beta1.EmbeddedAuthServerConfig) {
+ config.Issuer = "http://localhost:8080"
+ }),
+ },
+ {
+ name: "JWT-SVID client_credentials association with an http loopback issuer is admitted with the loopback opt-in",
+ trustDomains: true, clients: true,
+ principal: "spiffe://example.org/ns/default/agent", shouldAdmit: true,
+ mutate: jwtClientCredentials(func(config *mcpv1beta1.EmbeddedAuthServerConfig) {
+ config.Issuer = "http://localhost:8080"
+ config.InsecureAllowConfidentialOverLoopbackHTTP = true
+ }),
+ },
+ {
+ name: "JWT-SVID token exchange plus X.509 client_credentials on separate associations with insecureAllowHTTP is admitted",
+ trustDomains: true, clients: true,
+ principal: "spiffe://example.org/ns/default/agent", shouldAdmit: true,
+ mutate: jwtTokenExchangePlusX509ClientCredentials(func(config *mcpv1beta1.EmbeddedAuthServerConfig) {
+ config.InsecureAllowHTTP = true
+ }),
+ },
+ {
+ name: "JWT-SVID token exchange plus X.509 client_credentials on separate associations with an http loopback issuer is admitted without the loopback opt-in",
+ trustDomains: true, clients: true,
+ principal: "spiffe://example.org/ns/default/agent", shouldAdmit: true,
+ mutate: jwtTokenExchangePlusX509ClientCredentials(func(config *mcpv1beta1.EmbeddedAuthServerConfig) {
+ config.Issuer = "http://localhost:8080"
+ }),
+ },
+ {
+ name: "X.509 client_credentials association with insecureAllowHTTP is unaffected", trustDomains: true, clients: true,
+ principal: "spiffe://example.org/ns/default/agent", shouldAdmit: true,
+ mutate: func(config *mcpv1beta1.EmbeddedAuthServerConfig) {
+ config.InsecureAllowHTTP = true
+ config.InboundGrants.SPIFFEClientAuth[0].GrantTypes = []string{"client_credentials"}
+ },
+ },
{
name: "JWT-SVID association with an http loopback issuer is admitted without the loopback opt-in", trustDomains: true, clients: true,
principal: "spiffe://example.org/ns/default/agent", shouldAdmit: true,
@@ -466,4 +567,16 @@ var _ = Describe("MCPExternalAuthConfig SPIFFE CEL validation", func() {
Expect(err.Error()).To(ContainSubstring(test.errMatch))
})
}
+
+ It("defaults grantTypes to token exchange when omitted", func() {
+ config := makeAuthConfig("spiffe-grant-types-default", true, true, "spiffe://example.org/ns/default/agent")
+ config.Spec.EmbeddedAuthServer.InboundGrants.SPIFFEClientAuth[0].GrantTypes = nil
+ Expect(k8sClient.Create(ctx, config)).To(Succeed())
+ DeferCleanup(func() { Expect(k8sClient.Delete(ctx, config)).To(Succeed()) })
+
+ stored := &mcpv1beta1.MCPExternalAuthConfig{}
+ Expect(k8sClient.Get(ctx, types.NamespacedName{Name: config.Name, Namespace: config.Namespace}, stored)).To(Succeed())
+ Expect(stored.Spec.EmbeddedAuthServer.InboundGrants.SPIFFEClientAuth[0].GrantTypes).
+ To(Equal([]string{"urn:ietf:params:oauth:grant-type:token-exchange"}))
+ })
})
diff --git a/deploy/charts/operator-crds/files/crds/toolhive.stacklok.dev_mcpexternalauthconfigs.yaml b/deploy/charts/operator-crds/files/crds/toolhive.stacklok.dev_mcpexternalauthconfigs.yaml
index 4c51906c88..dd15107102 100644
--- a/deploy/charts/operator-crds/files/crds/toolhive.stacklok.dev_mcpexternalauthconfigs.yaml
+++ b/deploy/charts/operator-crds/files/crds/toolhive.stacklok.dev_mcpexternalauthconfigs.yaml
@@ -555,9 +555,6 @@ spec:
authenticate with a JWT-SVID or an X.509-SVID and have no client secret.
Trust material comes from the declared bundle source (see
SPIFFETrustDomainConfig's doc comment).
-
- The CRD does not expose grantTypes. The converter always supplies the
- RFC 8693 token-exchange grant instead of letting it be configured.
properties:
audiences:
description: |-
@@ -581,6 +578,27 @@ spec:
maxLength: 253
minLength: 1
type: string
+ grantTypes:
+ default:
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ description: |-
+ GrantTypes contains the OAuth grants permitted for this association.
+ It defaults to the token-exchange grant when omitted, which is what the
+ operator configured before this field existed. List client_credentials
+ to opt in to the SPIFFE-bound client credentials grant. The list alone
+ decides which grants the association may use: client authentication does
+ not confer any grant, and there is no separate per-grant enable switch.
+ Use urn:ietf:params:oauth:grant-type:token-exchange for RFC 8693 token
+ exchange.
+ items:
+ enum:
+ - client_credentials
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ type: string
+ maxItems: 2
+ minItems: 1
+ type: array
+ x-kubernetes-list-type: set
methods:
description: |-
Methods are the credential types this association may authenticate
@@ -615,8 +633,9 @@ spec:
allowlist membership is validated at reconcile time, not admission.
Shape (a well-formed absolute HTTP(S) URI) is independent of that
derived allowlist and is validated here. Required, with at least one
- entry, for every association: token exchange takes exactly one resource
- per request and grants it as the token audience.
+ entry, for every association: client_credentials and token exchange each
+ take exactly one resource per request and grant it as the token
+ audience.
items:
maxLength: 2048
minLength: 1
@@ -803,9 +822,12 @@ spec:
default: false
description: |-
InsecureAllowConfidentialOverLoopbackHTTP opts in to confidential
- Dynamic Client Registration (DCR) and delegate clients when issuer is a
- plain-HTTP loopback URL (e.g. "http://localhost:8080"). Without this
- flag, that combination is rejected at reconcile time: a loopback http://
+ Dynamic Client Registration (DCR), delegate clients and SPIFFE
+ associations that have spiffe_jwt in methods and client_credentials in
+ grantTypes on the same association, when issuer is a plain-HTTP loopback
+ URL (e.g. "http://localhost:8080"). Without this
+ flag, that combination is rejected at admission, and reconcile additionally
+ requires the issuer host to be loopback. A loopback http://
issuer is normally fine for local development since the traffic never
leaves the machine, but confidential clients send secrets over cleartext.
Forcing TLS onto every loopback deployment instead would just push
@@ -836,8 +858,10 @@ spec:
One combination is rejected at admission on all three CRDs regardless of the
above: setting this field alongside confidential client registration or
- delegate clients, which would issue or use client secrets in cleartext over
- an unauthenticated endpoint (see the XValidation rule on
+ delegate clients, or a SPIFFE association that has spiffe_jwt in methods and
+ client_credentials in grantTypes on the same association, which would issue
+ or use client secrets or JWT-SVIDs in cleartext over an unauthenticated
+ endpoint (see the XValidation rule on
EmbeddedAuthServerConfig).
type: boolean
issuer:
@@ -2632,27 +2656,36 @@ spec:
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.spiffeClientAuth)
|| self.inboundGrants.spiffeClientAuth.all(client, !client.clientId.matches(''^[A-Za-z][A-Za-z0-9+.-]*://.+''))'
- message: insecureAllowHTTP cannot be combined with confidential
- client registration or delegateClients; client secrets would be
- issued or used in cleartext over an unauthenticated endpoint
+ client registration, delegateClients or JWT-SVID SPIFFE associations
+ that grant client_credentials; client secrets or JWT-SVIDs would
+ be issued or used in cleartext over an unauthenticated endpoint
rule: '!(has(self.insecureAllowHTTP) && self.insecureAllowHTTP &&
((has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
|| (has(self.delegateClients) && size(self.delegateClients) >
0) || (has(self.inboundGrants) && has(self.inboundGrants.tokenExchange)
&& has(self.inboundGrants.tokenExchange.delegateClients) && size(self.inboundGrants.tokenExchange.delegateClients)
- > 0)))'
+ > 0) || (has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes))))'
- message: forceConfidentialRedirectUris requires allowConfidentialClientRegistration
to be true
rule: (!has(self.forceConfidentialRedirectUris) || size(self.forceConfidentialRedirectUris)
== 0) || (has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
- - message: confidential client registration or delegateClients with
- an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP
- to be explicitly enabled; the issuer must still be loopback
+ - message: confidential client registration, delegateClients or JWT-SVID
+ SPIFFE associations that grant client_credentials with an HTTP
+ issuer require insecureAllowConfidentialOverLoopbackHTTP to be
+ explicitly enabled; the issuer must still be loopback
rule: '!self.issuer.startsWith(''http://'') || (has(self.insecureAllowConfidentialOverLoopbackHTTP)
&& self.insecureAllowConfidentialOverLoopbackHTTP) || ((!has(self.allowConfidentialClientRegistration)
|| !self.allowConfidentialClientRegistration) && (!has(self.delegateClients)
|| size(self.delegateClients) == 0) && (!has(self.inboundGrants)
|| !has(self.inboundGrants.tokenExchange) || !has(self.inboundGrants.tokenExchange.delegateClients)
- || size(self.inboundGrants.tokenExchange.delegateClients) == 0))'
+ || size(self.inboundGrants.tokenExchange.delegateClients) == 0)
+ && !(has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes)))'
- message: canonical tokenExchange conflicts with legacy delegateClients
or RFC 8693 trusted issuer policy
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.tokenExchange)
@@ -3698,9 +3731,6 @@ spec:
authenticate with a JWT-SVID or an X.509-SVID and have no client secret.
Trust material comes from the declared bundle source (see
SPIFFETrustDomainConfig's doc comment).
-
- The CRD does not expose grantTypes. The converter always supplies the
- RFC 8693 token-exchange grant instead of letting it be configured.
properties:
audiences:
description: |-
@@ -3724,6 +3754,27 @@ spec:
maxLength: 253
minLength: 1
type: string
+ grantTypes:
+ default:
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ description: |-
+ GrantTypes contains the OAuth grants permitted for this association.
+ It defaults to the token-exchange grant when omitted, which is what the
+ operator configured before this field existed. List client_credentials
+ to opt in to the SPIFFE-bound client credentials grant. The list alone
+ decides which grants the association may use: client authentication does
+ not confer any grant, and there is no separate per-grant enable switch.
+ Use urn:ietf:params:oauth:grant-type:token-exchange for RFC 8693 token
+ exchange.
+ items:
+ enum:
+ - client_credentials
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ type: string
+ maxItems: 2
+ minItems: 1
+ type: array
+ x-kubernetes-list-type: set
methods:
description: |-
Methods are the credential types this association may authenticate
@@ -3758,8 +3809,9 @@ spec:
allowlist membership is validated at reconcile time, not admission.
Shape (a well-formed absolute HTTP(S) URI) is independent of that
derived allowlist and is validated here. Required, with at least one
- entry, for every association: token exchange takes exactly one resource
- per request and grants it as the token audience.
+ entry, for every association: client_credentials and token exchange each
+ take exactly one resource per request and grant it as the token
+ audience.
items:
maxLength: 2048
minLength: 1
@@ -3946,9 +3998,12 @@ spec:
default: false
description: |-
InsecureAllowConfidentialOverLoopbackHTTP opts in to confidential
- Dynamic Client Registration (DCR) and delegate clients when issuer is a
- plain-HTTP loopback URL (e.g. "http://localhost:8080"). Without this
- flag, that combination is rejected at reconcile time: a loopback http://
+ Dynamic Client Registration (DCR), delegate clients and SPIFFE
+ associations that have spiffe_jwt in methods and client_credentials in
+ grantTypes on the same association, when issuer is a plain-HTTP loopback
+ URL (e.g. "http://localhost:8080"). Without this
+ flag, that combination is rejected at admission, and reconcile additionally
+ requires the issuer host to be loopback. A loopback http://
issuer is normally fine for local development since the traffic never
leaves the machine, but confidential clients send secrets over cleartext.
Forcing TLS onto every loopback deployment instead would just push
@@ -3979,8 +4034,10 @@ spec:
One combination is rejected at admission on all three CRDs regardless of the
above: setting this field alongside confidential client registration or
- delegate clients, which would issue or use client secrets in cleartext over
- an unauthenticated endpoint (see the XValidation rule on
+ delegate clients, or a SPIFFE association that has spiffe_jwt in methods and
+ client_credentials in grantTypes on the same association, which would issue
+ or use client secrets or JWT-SVIDs in cleartext over an unauthenticated
+ endpoint (see the XValidation rule on
EmbeddedAuthServerConfig).
type: boolean
issuer:
@@ -5775,27 +5832,36 @@ spec:
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.spiffeClientAuth)
|| self.inboundGrants.spiffeClientAuth.all(client, !client.clientId.matches(''^[A-Za-z][A-Za-z0-9+.-]*://.+''))'
- message: insecureAllowHTTP cannot be combined with confidential
- client registration or delegateClients; client secrets would be
- issued or used in cleartext over an unauthenticated endpoint
+ client registration, delegateClients or JWT-SVID SPIFFE associations
+ that grant client_credentials; client secrets or JWT-SVIDs would
+ be issued or used in cleartext over an unauthenticated endpoint
rule: '!(has(self.insecureAllowHTTP) && self.insecureAllowHTTP &&
((has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
|| (has(self.delegateClients) && size(self.delegateClients) >
0) || (has(self.inboundGrants) && has(self.inboundGrants.tokenExchange)
&& has(self.inboundGrants.tokenExchange.delegateClients) && size(self.inboundGrants.tokenExchange.delegateClients)
- > 0)))'
+ > 0) || (has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes))))'
- message: forceConfidentialRedirectUris requires allowConfidentialClientRegistration
to be true
rule: (!has(self.forceConfidentialRedirectUris) || size(self.forceConfidentialRedirectUris)
== 0) || (has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
- - message: confidential client registration or delegateClients with
- an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP
- to be explicitly enabled; the issuer must still be loopback
+ - message: confidential client registration, delegateClients or JWT-SVID
+ SPIFFE associations that grant client_credentials with an HTTP
+ issuer require insecureAllowConfidentialOverLoopbackHTTP to be
+ explicitly enabled; the issuer must still be loopback
rule: '!self.issuer.startsWith(''http://'') || (has(self.insecureAllowConfidentialOverLoopbackHTTP)
&& self.insecureAllowConfidentialOverLoopbackHTTP) || ((!has(self.allowConfidentialClientRegistration)
|| !self.allowConfidentialClientRegistration) && (!has(self.delegateClients)
|| size(self.delegateClients) == 0) && (!has(self.inboundGrants)
|| !has(self.inboundGrants.tokenExchange) || !has(self.inboundGrants.tokenExchange.delegateClients)
- || size(self.inboundGrants.tokenExchange.delegateClients) == 0))'
+ || size(self.inboundGrants.tokenExchange.delegateClients) == 0)
+ && !(has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes)))'
- message: canonical tokenExchange conflicts with legacy delegateClients
or RFC 8693 trusted issuer policy
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.tokenExchange)
diff --git a/deploy/charts/operator-crds/files/crds/toolhive.stacklok.dev_virtualmcpservers.yaml b/deploy/charts/operator-crds/files/crds/toolhive.stacklok.dev_virtualmcpservers.yaml
index 08c8b7a2d6..c03b3bec25 100644
--- a/deploy/charts/operator-crds/files/crds/toolhive.stacklok.dev_virtualmcpservers.yaml
+++ b/deploy/charts/operator-crds/files/crds/toolhive.stacklok.dev_virtualmcpservers.yaml
@@ -442,9 +442,6 @@ spec:
authenticate with a JWT-SVID or an X.509-SVID and have no client secret.
Trust material comes from the declared bundle source (see
SPIFFETrustDomainConfig's doc comment).
-
- The CRD does not expose grantTypes. The converter always supplies the
- RFC 8693 token-exchange grant instead of letting it be configured.
properties:
audiences:
description: |-
@@ -468,6 +465,27 @@ spec:
maxLength: 253
minLength: 1
type: string
+ grantTypes:
+ default:
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ description: |-
+ GrantTypes contains the OAuth grants permitted for this association.
+ It defaults to the token-exchange grant when omitted, which is what the
+ operator configured before this field existed. List client_credentials
+ to opt in to the SPIFFE-bound client credentials grant. The list alone
+ decides which grants the association may use: client authentication does
+ not confer any grant, and there is no separate per-grant enable switch.
+ Use urn:ietf:params:oauth:grant-type:token-exchange for RFC 8693 token
+ exchange.
+ items:
+ enum:
+ - client_credentials
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ type: string
+ maxItems: 2
+ minItems: 1
+ type: array
+ x-kubernetes-list-type: set
methods:
description: |-
Methods are the credential types this association may authenticate
@@ -502,8 +520,9 @@ spec:
allowlist membership is validated at reconcile time, not admission.
Shape (a well-formed absolute HTTP(S) URI) is independent of that
derived allowlist and is validated here. Required, with at least one
- entry, for every association: token exchange takes exactly one resource
- per request and grants it as the token audience.
+ entry, for every association: client_credentials and token exchange each
+ take exactly one resource per request and grant it as the token
+ audience.
items:
maxLength: 2048
minLength: 1
@@ -690,9 +709,12 @@ spec:
default: false
description: |-
InsecureAllowConfidentialOverLoopbackHTTP opts in to confidential
- Dynamic Client Registration (DCR) and delegate clients when issuer is a
- plain-HTTP loopback URL (e.g. "http://localhost:8080"). Without this
- flag, that combination is rejected at reconcile time: a loopback http://
+ Dynamic Client Registration (DCR), delegate clients and SPIFFE
+ associations that have spiffe_jwt in methods and client_credentials in
+ grantTypes on the same association, when issuer is a plain-HTTP loopback
+ URL (e.g. "http://localhost:8080"). Without this
+ flag, that combination is rejected at admission, and reconcile additionally
+ requires the issuer host to be loopback. A loopback http://
issuer is normally fine for local development since the traffic never
leaves the machine, but confidential clients send secrets over cleartext.
Forcing TLS onto every loopback deployment instead would just push
@@ -723,8 +745,10 @@ spec:
One combination is rejected at admission on all three CRDs regardless of the
above: setting this field alongside confidential client registration or
- delegate clients, which would issue or use client secrets in cleartext over
- an unauthenticated endpoint (see the XValidation rule on
+ delegate clients, or a SPIFFE association that has spiffe_jwt in methods and
+ client_credentials in grantTypes on the same association, which would issue
+ or use client secrets or JWT-SVIDs in cleartext over an unauthenticated
+ endpoint (see the XValidation rule on
EmbeddedAuthServerConfig).
type: boolean
issuer:
@@ -2519,27 +2543,36 @@ spec:
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.spiffeClientAuth)
|| self.inboundGrants.spiffeClientAuth.all(client, !client.clientId.matches(''^[A-Za-z][A-Za-z0-9+.-]*://.+''))'
- message: insecureAllowHTTP cannot be combined with confidential
- client registration or delegateClients; client secrets would be
- issued or used in cleartext over an unauthenticated endpoint
+ client registration, delegateClients or JWT-SVID SPIFFE associations
+ that grant client_credentials; client secrets or JWT-SVIDs would
+ be issued or used in cleartext over an unauthenticated endpoint
rule: '!(has(self.insecureAllowHTTP) && self.insecureAllowHTTP &&
((has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
|| (has(self.delegateClients) && size(self.delegateClients) >
0) || (has(self.inboundGrants) && has(self.inboundGrants.tokenExchange)
&& has(self.inboundGrants.tokenExchange.delegateClients) && size(self.inboundGrants.tokenExchange.delegateClients)
- > 0)))'
+ > 0) || (has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes))))'
- message: forceConfidentialRedirectUris requires allowConfidentialClientRegistration
to be true
rule: (!has(self.forceConfidentialRedirectUris) || size(self.forceConfidentialRedirectUris)
== 0) || (has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
- - message: confidential client registration or delegateClients with
- an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP
- to be explicitly enabled; the issuer must still be loopback
+ - message: confidential client registration, delegateClients or JWT-SVID
+ SPIFFE associations that grant client_credentials with an HTTP
+ issuer require insecureAllowConfidentialOverLoopbackHTTP to be
+ explicitly enabled; the issuer must still be loopback
rule: '!self.issuer.startsWith(''http://'') || (has(self.insecureAllowConfidentialOverLoopbackHTTP)
&& self.insecureAllowConfidentialOverLoopbackHTTP) || ((!has(self.allowConfidentialClientRegistration)
|| !self.allowConfidentialClientRegistration) && (!has(self.delegateClients)
|| size(self.delegateClients) == 0) && (!has(self.inboundGrants)
|| !has(self.inboundGrants.tokenExchange) || !has(self.inboundGrants.tokenExchange.delegateClients)
- || size(self.inboundGrants.tokenExchange.delegateClients) == 0))'
+ || size(self.inboundGrants.tokenExchange.delegateClients) == 0)
+ && !(has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes)))'
- message: canonical tokenExchange conflicts with legacy delegateClients
or RFC 8693 trusted issuer policy
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.tokenExchange)
@@ -5977,9 +6010,6 @@ spec:
authenticate with a JWT-SVID or an X.509-SVID and have no client secret.
Trust material comes from the declared bundle source (see
SPIFFETrustDomainConfig's doc comment).
-
- The CRD does not expose grantTypes. The converter always supplies the
- RFC 8693 token-exchange grant instead of letting it be configured.
properties:
audiences:
description: |-
@@ -6003,6 +6033,27 @@ spec:
maxLength: 253
minLength: 1
type: string
+ grantTypes:
+ default:
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ description: |-
+ GrantTypes contains the OAuth grants permitted for this association.
+ It defaults to the token-exchange grant when omitted, which is what the
+ operator configured before this field existed. List client_credentials
+ to opt in to the SPIFFE-bound client credentials grant. The list alone
+ decides which grants the association may use: client authentication does
+ not confer any grant, and there is no separate per-grant enable switch.
+ Use urn:ietf:params:oauth:grant-type:token-exchange for RFC 8693 token
+ exchange.
+ items:
+ enum:
+ - client_credentials
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ type: string
+ maxItems: 2
+ minItems: 1
+ type: array
+ x-kubernetes-list-type: set
methods:
description: |-
Methods are the credential types this association may authenticate
@@ -6037,8 +6088,9 @@ spec:
allowlist membership is validated at reconcile time, not admission.
Shape (a well-formed absolute HTTP(S) URI) is independent of that
derived allowlist and is validated here. Required, with at least one
- entry, for every association: token exchange takes exactly one resource
- per request and grants it as the token audience.
+ entry, for every association: client_credentials and token exchange each
+ take exactly one resource per request and grant it as the token
+ audience.
items:
maxLength: 2048
minLength: 1
@@ -6225,9 +6277,12 @@ spec:
default: false
description: |-
InsecureAllowConfidentialOverLoopbackHTTP opts in to confidential
- Dynamic Client Registration (DCR) and delegate clients when issuer is a
- plain-HTTP loopback URL (e.g. "http://localhost:8080"). Without this
- flag, that combination is rejected at reconcile time: a loopback http://
+ Dynamic Client Registration (DCR), delegate clients and SPIFFE
+ associations that have spiffe_jwt in methods and client_credentials in
+ grantTypes on the same association, when issuer is a plain-HTTP loopback
+ URL (e.g. "http://localhost:8080"). Without this
+ flag, that combination is rejected at admission, and reconcile additionally
+ requires the issuer host to be loopback. A loopback http://
issuer is normally fine for local development since the traffic never
leaves the machine, but confidential clients send secrets over cleartext.
Forcing TLS onto every loopback deployment instead would just push
@@ -6258,8 +6313,10 @@ spec:
One combination is rejected at admission on all three CRDs regardless of the
above: setting this field alongside confidential client registration or
- delegate clients, which would issue or use client secrets in cleartext over
- an unauthenticated endpoint (see the XValidation rule on
+ delegate clients, or a SPIFFE association that has spiffe_jwt in methods and
+ client_credentials in grantTypes on the same association, which would issue
+ or use client secrets or JWT-SVIDs in cleartext over an unauthenticated
+ endpoint (see the XValidation rule on
EmbeddedAuthServerConfig).
type: boolean
issuer:
@@ -8054,27 +8111,36 @@ spec:
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.spiffeClientAuth)
|| self.inboundGrants.spiffeClientAuth.all(client, !client.clientId.matches(''^[A-Za-z][A-Za-z0-9+.-]*://.+''))'
- message: insecureAllowHTTP cannot be combined with confidential
- client registration or delegateClients; client secrets would be
- issued or used in cleartext over an unauthenticated endpoint
+ client registration, delegateClients or JWT-SVID SPIFFE associations
+ that grant client_credentials; client secrets or JWT-SVIDs would
+ be issued or used in cleartext over an unauthenticated endpoint
rule: '!(has(self.insecureAllowHTTP) && self.insecureAllowHTTP &&
((has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
|| (has(self.delegateClients) && size(self.delegateClients) >
0) || (has(self.inboundGrants) && has(self.inboundGrants.tokenExchange)
&& has(self.inboundGrants.tokenExchange.delegateClients) && size(self.inboundGrants.tokenExchange.delegateClients)
- > 0)))'
+ > 0) || (has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes))))'
- message: forceConfidentialRedirectUris requires allowConfidentialClientRegistration
to be true
rule: (!has(self.forceConfidentialRedirectUris) || size(self.forceConfidentialRedirectUris)
== 0) || (has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
- - message: confidential client registration or delegateClients with
- an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP
- to be explicitly enabled; the issuer must still be loopback
+ - message: confidential client registration, delegateClients or JWT-SVID
+ SPIFFE associations that grant client_credentials with an HTTP
+ issuer require insecureAllowConfidentialOverLoopbackHTTP to be
+ explicitly enabled; the issuer must still be loopback
rule: '!self.issuer.startsWith(''http://'') || (has(self.insecureAllowConfidentialOverLoopbackHTTP)
&& self.insecureAllowConfidentialOverLoopbackHTTP) || ((!has(self.allowConfidentialClientRegistration)
|| !self.allowConfidentialClientRegistration) && (!has(self.delegateClients)
|| size(self.delegateClients) == 0) && (!has(self.inboundGrants)
|| !has(self.inboundGrants.tokenExchange) || !has(self.inboundGrants.tokenExchange.delegateClients)
- || size(self.inboundGrants.tokenExchange.delegateClients) == 0))'
+ || size(self.inboundGrants.tokenExchange.delegateClients) == 0)
+ && !(has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes)))'
- message: canonical tokenExchange conflicts with legacy delegateClients
or RFC 8693 trusted issuer policy
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.tokenExchange)
diff --git a/deploy/charts/operator-crds/templates/toolhive.stacklok.dev_mcpexternalauthconfigs.yaml b/deploy/charts/operator-crds/templates/toolhive.stacklok.dev_mcpexternalauthconfigs.yaml
index ce562a6706..5be6a3c7dc 100644
--- a/deploy/charts/operator-crds/templates/toolhive.stacklok.dev_mcpexternalauthconfigs.yaml
+++ b/deploy/charts/operator-crds/templates/toolhive.stacklok.dev_mcpexternalauthconfigs.yaml
@@ -558,9 +558,6 @@ spec:
authenticate with a JWT-SVID or an X.509-SVID and have no client secret.
Trust material comes from the declared bundle source (see
SPIFFETrustDomainConfig's doc comment).
-
- The CRD does not expose grantTypes. The converter always supplies the
- RFC 8693 token-exchange grant instead of letting it be configured.
properties:
audiences:
description: |-
@@ -584,6 +581,27 @@ spec:
maxLength: 253
minLength: 1
type: string
+ grantTypes:
+ default:
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ description: |-
+ GrantTypes contains the OAuth grants permitted for this association.
+ It defaults to the token-exchange grant when omitted, which is what the
+ operator configured before this field existed. List client_credentials
+ to opt in to the SPIFFE-bound client credentials grant. The list alone
+ decides which grants the association may use: client authentication does
+ not confer any grant, and there is no separate per-grant enable switch.
+ Use urn:ietf:params:oauth:grant-type:token-exchange for RFC 8693 token
+ exchange.
+ items:
+ enum:
+ - client_credentials
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ type: string
+ maxItems: 2
+ minItems: 1
+ type: array
+ x-kubernetes-list-type: set
methods:
description: |-
Methods are the credential types this association may authenticate
@@ -618,8 +636,9 @@ spec:
allowlist membership is validated at reconcile time, not admission.
Shape (a well-formed absolute HTTP(S) URI) is independent of that
derived allowlist and is validated here. Required, with at least one
- entry, for every association: token exchange takes exactly one resource
- per request and grants it as the token audience.
+ entry, for every association: client_credentials and token exchange each
+ take exactly one resource per request and grant it as the token
+ audience.
items:
maxLength: 2048
minLength: 1
@@ -806,9 +825,12 @@ spec:
default: false
description: |-
InsecureAllowConfidentialOverLoopbackHTTP opts in to confidential
- Dynamic Client Registration (DCR) and delegate clients when issuer is a
- plain-HTTP loopback URL (e.g. "http://localhost:8080"). Without this
- flag, that combination is rejected at reconcile time: a loopback http://
+ Dynamic Client Registration (DCR), delegate clients and SPIFFE
+ associations that have spiffe_jwt in methods and client_credentials in
+ grantTypes on the same association, when issuer is a plain-HTTP loopback
+ URL (e.g. "http://localhost:8080"). Without this
+ flag, that combination is rejected at admission, and reconcile additionally
+ requires the issuer host to be loopback. A loopback http://
issuer is normally fine for local development since the traffic never
leaves the machine, but confidential clients send secrets over cleartext.
Forcing TLS onto every loopback deployment instead would just push
@@ -839,8 +861,10 @@ spec:
One combination is rejected at admission on all three CRDs regardless of the
above: setting this field alongside confidential client registration or
- delegate clients, which would issue or use client secrets in cleartext over
- an unauthenticated endpoint (see the XValidation rule on
+ delegate clients, or a SPIFFE association that has spiffe_jwt in methods and
+ client_credentials in grantTypes on the same association, which would issue
+ or use client secrets or JWT-SVIDs in cleartext over an unauthenticated
+ endpoint (see the XValidation rule on
EmbeddedAuthServerConfig).
type: boolean
issuer:
@@ -2635,27 +2659,36 @@ spec:
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.spiffeClientAuth)
|| self.inboundGrants.spiffeClientAuth.all(client, !client.clientId.matches(''^[A-Za-z][A-Za-z0-9+.-]*://.+''))'
- message: insecureAllowHTTP cannot be combined with confidential
- client registration or delegateClients; client secrets would be
- issued or used in cleartext over an unauthenticated endpoint
+ client registration, delegateClients or JWT-SVID SPIFFE associations
+ that grant client_credentials; client secrets or JWT-SVIDs would
+ be issued or used in cleartext over an unauthenticated endpoint
rule: '!(has(self.insecureAllowHTTP) && self.insecureAllowHTTP &&
((has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
|| (has(self.delegateClients) && size(self.delegateClients) >
0) || (has(self.inboundGrants) && has(self.inboundGrants.tokenExchange)
&& has(self.inboundGrants.tokenExchange.delegateClients) && size(self.inboundGrants.tokenExchange.delegateClients)
- > 0)))'
+ > 0) || (has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes))))'
- message: forceConfidentialRedirectUris requires allowConfidentialClientRegistration
to be true
rule: (!has(self.forceConfidentialRedirectUris) || size(self.forceConfidentialRedirectUris)
== 0) || (has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
- - message: confidential client registration or delegateClients with
- an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP
- to be explicitly enabled; the issuer must still be loopback
+ - message: confidential client registration, delegateClients or JWT-SVID
+ SPIFFE associations that grant client_credentials with an HTTP
+ issuer require insecureAllowConfidentialOverLoopbackHTTP to be
+ explicitly enabled; the issuer must still be loopback
rule: '!self.issuer.startsWith(''http://'') || (has(self.insecureAllowConfidentialOverLoopbackHTTP)
&& self.insecureAllowConfidentialOverLoopbackHTTP) || ((!has(self.allowConfidentialClientRegistration)
|| !self.allowConfidentialClientRegistration) && (!has(self.delegateClients)
|| size(self.delegateClients) == 0) && (!has(self.inboundGrants)
|| !has(self.inboundGrants.tokenExchange) || !has(self.inboundGrants.tokenExchange.delegateClients)
- || size(self.inboundGrants.tokenExchange.delegateClients) == 0))'
+ || size(self.inboundGrants.tokenExchange.delegateClients) == 0)
+ && !(has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes)))'
- message: canonical tokenExchange conflicts with legacy delegateClients
or RFC 8693 trusted issuer policy
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.tokenExchange)
@@ -3701,9 +3734,6 @@ spec:
authenticate with a JWT-SVID or an X.509-SVID and have no client secret.
Trust material comes from the declared bundle source (see
SPIFFETrustDomainConfig's doc comment).
-
- The CRD does not expose grantTypes. The converter always supplies the
- RFC 8693 token-exchange grant instead of letting it be configured.
properties:
audiences:
description: |-
@@ -3727,6 +3757,27 @@ spec:
maxLength: 253
minLength: 1
type: string
+ grantTypes:
+ default:
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ description: |-
+ GrantTypes contains the OAuth grants permitted for this association.
+ It defaults to the token-exchange grant when omitted, which is what the
+ operator configured before this field existed. List client_credentials
+ to opt in to the SPIFFE-bound client credentials grant. The list alone
+ decides which grants the association may use: client authentication does
+ not confer any grant, and there is no separate per-grant enable switch.
+ Use urn:ietf:params:oauth:grant-type:token-exchange for RFC 8693 token
+ exchange.
+ items:
+ enum:
+ - client_credentials
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ type: string
+ maxItems: 2
+ minItems: 1
+ type: array
+ x-kubernetes-list-type: set
methods:
description: |-
Methods are the credential types this association may authenticate
@@ -3761,8 +3812,9 @@ spec:
allowlist membership is validated at reconcile time, not admission.
Shape (a well-formed absolute HTTP(S) URI) is independent of that
derived allowlist and is validated here. Required, with at least one
- entry, for every association: token exchange takes exactly one resource
- per request and grants it as the token audience.
+ entry, for every association: client_credentials and token exchange each
+ take exactly one resource per request and grant it as the token
+ audience.
items:
maxLength: 2048
minLength: 1
@@ -3949,9 +4001,12 @@ spec:
default: false
description: |-
InsecureAllowConfidentialOverLoopbackHTTP opts in to confidential
- Dynamic Client Registration (DCR) and delegate clients when issuer is a
- plain-HTTP loopback URL (e.g. "http://localhost:8080"). Without this
- flag, that combination is rejected at reconcile time: a loopback http://
+ Dynamic Client Registration (DCR), delegate clients and SPIFFE
+ associations that have spiffe_jwt in methods and client_credentials in
+ grantTypes on the same association, when issuer is a plain-HTTP loopback
+ URL (e.g. "http://localhost:8080"). Without this
+ flag, that combination is rejected at admission, and reconcile additionally
+ requires the issuer host to be loopback. A loopback http://
issuer is normally fine for local development since the traffic never
leaves the machine, but confidential clients send secrets over cleartext.
Forcing TLS onto every loopback deployment instead would just push
@@ -3982,8 +4037,10 @@ spec:
One combination is rejected at admission on all three CRDs regardless of the
above: setting this field alongside confidential client registration or
- delegate clients, which would issue or use client secrets in cleartext over
- an unauthenticated endpoint (see the XValidation rule on
+ delegate clients, or a SPIFFE association that has spiffe_jwt in methods and
+ client_credentials in grantTypes on the same association, which would issue
+ or use client secrets or JWT-SVIDs in cleartext over an unauthenticated
+ endpoint (see the XValidation rule on
EmbeddedAuthServerConfig).
type: boolean
issuer:
@@ -5778,27 +5835,36 @@ spec:
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.spiffeClientAuth)
|| self.inboundGrants.spiffeClientAuth.all(client, !client.clientId.matches(''^[A-Za-z][A-Za-z0-9+.-]*://.+''))'
- message: insecureAllowHTTP cannot be combined with confidential
- client registration or delegateClients; client secrets would be
- issued or used in cleartext over an unauthenticated endpoint
+ client registration, delegateClients or JWT-SVID SPIFFE associations
+ that grant client_credentials; client secrets or JWT-SVIDs would
+ be issued or used in cleartext over an unauthenticated endpoint
rule: '!(has(self.insecureAllowHTTP) && self.insecureAllowHTTP &&
((has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
|| (has(self.delegateClients) && size(self.delegateClients) >
0) || (has(self.inboundGrants) && has(self.inboundGrants.tokenExchange)
&& has(self.inboundGrants.tokenExchange.delegateClients) && size(self.inboundGrants.tokenExchange.delegateClients)
- > 0)))'
+ > 0) || (has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes))))'
- message: forceConfidentialRedirectUris requires allowConfidentialClientRegistration
to be true
rule: (!has(self.forceConfidentialRedirectUris) || size(self.forceConfidentialRedirectUris)
== 0) || (has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
- - message: confidential client registration or delegateClients with
- an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP
- to be explicitly enabled; the issuer must still be loopback
+ - message: confidential client registration, delegateClients or JWT-SVID
+ SPIFFE associations that grant client_credentials with an HTTP
+ issuer require insecureAllowConfidentialOverLoopbackHTTP to be
+ explicitly enabled; the issuer must still be loopback
rule: '!self.issuer.startsWith(''http://'') || (has(self.insecureAllowConfidentialOverLoopbackHTTP)
&& self.insecureAllowConfidentialOverLoopbackHTTP) || ((!has(self.allowConfidentialClientRegistration)
|| !self.allowConfidentialClientRegistration) && (!has(self.delegateClients)
|| size(self.delegateClients) == 0) && (!has(self.inboundGrants)
|| !has(self.inboundGrants.tokenExchange) || !has(self.inboundGrants.tokenExchange.delegateClients)
- || size(self.inboundGrants.tokenExchange.delegateClients) == 0))'
+ || size(self.inboundGrants.tokenExchange.delegateClients) == 0)
+ && !(has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes)))'
- message: canonical tokenExchange conflicts with legacy delegateClients
or RFC 8693 trusted issuer policy
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.tokenExchange)
diff --git a/deploy/charts/operator-crds/templates/toolhive.stacklok.dev_virtualmcpservers.yaml b/deploy/charts/operator-crds/templates/toolhive.stacklok.dev_virtualmcpservers.yaml
index 3f0f8bc53f..8cd3fe82d9 100644
--- a/deploy/charts/operator-crds/templates/toolhive.stacklok.dev_virtualmcpservers.yaml
+++ b/deploy/charts/operator-crds/templates/toolhive.stacklok.dev_virtualmcpservers.yaml
@@ -445,9 +445,6 @@ spec:
authenticate with a JWT-SVID or an X.509-SVID and have no client secret.
Trust material comes from the declared bundle source (see
SPIFFETrustDomainConfig's doc comment).
-
- The CRD does not expose grantTypes. The converter always supplies the
- RFC 8693 token-exchange grant instead of letting it be configured.
properties:
audiences:
description: |-
@@ -471,6 +468,27 @@ spec:
maxLength: 253
minLength: 1
type: string
+ grantTypes:
+ default:
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ description: |-
+ GrantTypes contains the OAuth grants permitted for this association.
+ It defaults to the token-exchange grant when omitted, which is what the
+ operator configured before this field existed. List client_credentials
+ to opt in to the SPIFFE-bound client credentials grant. The list alone
+ decides which grants the association may use: client authentication does
+ not confer any grant, and there is no separate per-grant enable switch.
+ Use urn:ietf:params:oauth:grant-type:token-exchange for RFC 8693 token
+ exchange.
+ items:
+ enum:
+ - client_credentials
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ type: string
+ maxItems: 2
+ minItems: 1
+ type: array
+ x-kubernetes-list-type: set
methods:
description: |-
Methods are the credential types this association may authenticate
@@ -505,8 +523,9 @@ spec:
allowlist membership is validated at reconcile time, not admission.
Shape (a well-formed absolute HTTP(S) URI) is independent of that
derived allowlist and is validated here. Required, with at least one
- entry, for every association: token exchange takes exactly one resource
- per request and grants it as the token audience.
+ entry, for every association: client_credentials and token exchange each
+ take exactly one resource per request and grant it as the token
+ audience.
items:
maxLength: 2048
minLength: 1
@@ -693,9 +712,12 @@ spec:
default: false
description: |-
InsecureAllowConfidentialOverLoopbackHTTP opts in to confidential
- Dynamic Client Registration (DCR) and delegate clients when issuer is a
- plain-HTTP loopback URL (e.g. "http://localhost:8080"). Without this
- flag, that combination is rejected at reconcile time: a loopback http://
+ Dynamic Client Registration (DCR), delegate clients and SPIFFE
+ associations that have spiffe_jwt in methods and client_credentials in
+ grantTypes on the same association, when issuer is a plain-HTTP loopback
+ URL (e.g. "http://localhost:8080"). Without this
+ flag, that combination is rejected at admission, and reconcile additionally
+ requires the issuer host to be loopback. A loopback http://
issuer is normally fine for local development since the traffic never
leaves the machine, but confidential clients send secrets over cleartext.
Forcing TLS onto every loopback deployment instead would just push
@@ -726,8 +748,10 @@ spec:
One combination is rejected at admission on all three CRDs regardless of the
above: setting this field alongside confidential client registration or
- delegate clients, which would issue or use client secrets in cleartext over
- an unauthenticated endpoint (see the XValidation rule on
+ delegate clients, or a SPIFFE association that has spiffe_jwt in methods and
+ client_credentials in grantTypes on the same association, which would issue
+ or use client secrets or JWT-SVIDs in cleartext over an unauthenticated
+ endpoint (see the XValidation rule on
EmbeddedAuthServerConfig).
type: boolean
issuer:
@@ -2522,27 +2546,36 @@ spec:
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.spiffeClientAuth)
|| self.inboundGrants.spiffeClientAuth.all(client, !client.clientId.matches(''^[A-Za-z][A-Za-z0-9+.-]*://.+''))'
- message: insecureAllowHTTP cannot be combined with confidential
- client registration or delegateClients; client secrets would be
- issued or used in cleartext over an unauthenticated endpoint
+ client registration, delegateClients or JWT-SVID SPIFFE associations
+ that grant client_credentials; client secrets or JWT-SVIDs would
+ be issued or used in cleartext over an unauthenticated endpoint
rule: '!(has(self.insecureAllowHTTP) && self.insecureAllowHTTP &&
((has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
|| (has(self.delegateClients) && size(self.delegateClients) >
0) || (has(self.inboundGrants) && has(self.inboundGrants.tokenExchange)
&& has(self.inboundGrants.tokenExchange.delegateClients) && size(self.inboundGrants.tokenExchange.delegateClients)
- > 0)))'
+ > 0) || (has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes))))'
- message: forceConfidentialRedirectUris requires allowConfidentialClientRegistration
to be true
rule: (!has(self.forceConfidentialRedirectUris) || size(self.forceConfidentialRedirectUris)
== 0) || (has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
- - message: confidential client registration or delegateClients with
- an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP
- to be explicitly enabled; the issuer must still be loopback
+ - message: confidential client registration, delegateClients or JWT-SVID
+ SPIFFE associations that grant client_credentials with an HTTP
+ issuer require insecureAllowConfidentialOverLoopbackHTTP to be
+ explicitly enabled; the issuer must still be loopback
rule: '!self.issuer.startsWith(''http://'') || (has(self.insecureAllowConfidentialOverLoopbackHTTP)
&& self.insecureAllowConfidentialOverLoopbackHTTP) || ((!has(self.allowConfidentialClientRegistration)
|| !self.allowConfidentialClientRegistration) && (!has(self.delegateClients)
|| size(self.delegateClients) == 0) && (!has(self.inboundGrants)
|| !has(self.inboundGrants.tokenExchange) || !has(self.inboundGrants.tokenExchange.delegateClients)
- || size(self.inboundGrants.tokenExchange.delegateClients) == 0))'
+ || size(self.inboundGrants.tokenExchange.delegateClients) == 0)
+ && !(has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes)))'
- message: canonical tokenExchange conflicts with legacy delegateClients
or RFC 8693 trusted issuer policy
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.tokenExchange)
@@ -5980,9 +6013,6 @@ spec:
authenticate with a JWT-SVID or an X.509-SVID and have no client secret.
Trust material comes from the declared bundle source (see
SPIFFETrustDomainConfig's doc comment).
-
- The CRD does not expose grantTypes. The converter always supplies the
- RFC 8693 token-exchange grant instead of letting it be configured.
properties:
audiences:
description: |-
@@ -6006,6 +6036,27 @@ spec:
maxLength: 253
minLength: 1
type: string
+ grantTypes:
+ default:
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ description: |-
+ GrantTypes contains the OAuth grants permitted for this association.
+ It defaults to the token-exchange grant when omitted, which is what the
+ operator configured before this field existed. List client_credentials
+ to opt in to the SPIFFE-bound client credentials grant. The list alone
+ decides which grants the association may use: client authentication does
+ not confer any grant, and there is no separate per-grant enable switch.
+ Use urn:ietf:params:oauth:grant-type:token-exchange for RFC 8693 token
+ exchange.
+ items:
+ enum:
+ - client_credentials
+ - urn:ietf:params:oauth:grant-type:token-exchange
+ type: string
+ maxItems: 2
+ minItems: 1
+ type: array
+ x-kubernetes-list-type: set
methods:
description: |-
Methods are the credential types this association may authenticate
@@ -6040,8 +6091,9 @@ spec:
allowlist membership is validated at reconcile time, not admission.
Shape (a well-formed absolute HTTP(S) URI) is independent of that
derived allowlist and is validated here. Required, with at least one
- entry, for every association: token exchange takes exactly one resource
- per request and grants it as the token audience.
+ entry, for every association: client_credentials and token exchange each
+ take exactly one resource per request and grant it as the token
+ audience.
items:
maxLength: 2048
minLength: 1
@@ -6228,9 +6280,12 @@ spec:
default: false
description: |-
InsecureAllowConfidentialOverLoopbackHTTP opts in to confidential
- Dynamic Client Registration (DCR) and delegate clients when issuer is a
- plain-HTTP loopback URL (e.g. "http://localhost:8080"). Without this
- flag, that combination is rejected at reconcile time: a loopback http://
+ Dynamic Client Registration (DCR), delegate clients and SPIFFE
+ associations that have spiffe_jwt in methods and client_credentials in
+ grantTypes on the same association, when issuer is a plain-HTTP loopback
+ URL (e.g. "http://localhost:8080"). Without this
+ flag, that combination is rejected at admission, and reconcile additionally
+ requires the issuer host to be loopback. A loopback http://
issuer is normally fine for local development since the traffic never
leaves the machine, but confidential clients send secrets over cleartext.
Forcing TLS onto every loopback deployment instead would just push
@@ -6261,8 +6316,10 @@ spec:
One combination is rejected at admission on all three CRDs regardless of the
above: setting this field alongside confidential client registration or
- delegate clients, which would issue or use client secrets in cleartext over
- an unauthenticated endpoint (see the XValidation rule on
+ delegate clients, or a SPIFFE association that has spiffe_jwt in methods and
+ client_credentials in grantTypes on the same association, which would issue
+ or use client secrets or JWT-SVIDs in cleartext over an unauthenticated
+ endpoint (see the XValidation rule on
EmbeddedAuthServerConfig).
type: boolean
issuer:
@@ -8057,27 +8114,36 @@ spec:
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.spiffeClientAuth)
|| self.inboundGrants.spiffeClientAuth.all(client, !client.clientId.matches(''^[A-Za-z][A-Za-z0-9+.-]*://.+''))'
- message: insecureAllowHTTP cannot be combined with confidential
- client registration or delegateClients; client secrets would be
- issued or used in cleartext over an unauthenticated endpoint
+ client registration, delegateClients or JWT-SVID SPIFFE associations
+ that grant client_credentials; client secrets or JWT-SVIDs would
+ be issued or used in cleartext over an unauthenticated endpoint
rule: '!(has(self.insecureAllowHTTP) && self.insecureAllowHTTP &&
((has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
|| (has(self.delegateClients) && size(self.delegateClients) >
0) || (has(self.inboundGrants) && has(self.inboundGrants.tokenExchange)
&& has(self.inboundGrants.tokenExchange.delegateClients) && size(self.inboundGrants.tokenExchange.delegateClients)
- > 0)))'
+ > 0) || (has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes))))'
- message: forceConfidentialRedirectUris requires allowConfidentialClientRegistration
to be true
rule: (!has(self.forceConfidentialRedirectUris) || size(self.forceConfidentialRedirectUris)
== 0) || (has(self.allowConfidentialClientRegistration) && self.allowConfidentialClientRegistration)
- - message: confidential client registration or delegateClients with
- an HTTP issuer require insecureAllowConfidentialOverLoopbackHTTP
- to be explicitly enabled; the issuer must still be loopback
+ - message: confidential client registration, delegateClients or JWT-SVID
+ SPIFFE associations that grant client_credentials with an HTTP
+ issuer require insecureAllowConfidentialOverLoopbackHTTP to be
+ explicitly enabled; the issuer must still be loopback
rule: '!self.issuer.startsWith(''http://'') || (has(self.insecureAllowConfidentialOverLoopbackHTTP)
&& self.insecureAllowConfidentialOverLoopbackHTTP) || ((!has(self.allowConfidentialClientRegistration)
|| !self.allowConfidentialClientRegistration) && (!has(self.delegateClients)
|| size(self.delegateClients) == 0) && (!has(self.inboundGrants)
|| !has(self.inboundGrants.tokenExchange) || !has(self.inboundGrants.tokenExchange.delegateClients)
- || size(self.inboundGrants.tokenExchange.delegateClients) == 0))'
+ || size(self.inboundGrants.tokenExchange.delegateClients) == 0)
+ && !(has(self.inboundGrants) && has(self.inboundGrants.spiffeClientAuth)
+ && self.inboundGrants.spiffeClientAuth.exists(a, ''spiffe_jwt''
+ in a.methods && has(a.grantTypes) && ''client_credentials'' in
+ a.grantTypes)))'
- message: canonical tokenExchange conflicts with legacy delegateClients
or RFC 8693 trusted issuer policy
rule: '!has(self.inboundGrants) || !has(self.inboundGrants.tokenExchange)
diff --git a/docs/arch/18-spiffe-association-declarations.md b/docs/arch/18-spiffe-association-declarations.md
index 74397a9ebb..40dbdccd83 100644
--- a/docs/arch/18-spiffe-association-declarations.md
+++ b/docs/arch/18-spiffe-association-declarations.md
@@ -33,7 +33,7 @@ Configuration separates top-level trust declarations from canonical client assoc
- `spiffe_trust_domains` in `RunConfig` (`spiffeTrustDomains` in the CRD) names a canonical SPIFFE trust domain, declares the methods intended for authentication, and selects a trust-bundle source.
- `inbound_grants.spiffe_client_auth` in `RunConfig` (`inboundGrants.spiffeClientAuth` in the CRD) associates an exact SPIFFE ID or a terminal `/*` descendant `principalPattern` with one explicit OAuth `client_id`, methods, resources, and scopes. This is a sibling of `inbound_grants.token_exchange` and `inbound_grants.jwt_bearer`, not nested under either — client authentication does not by itself confer a grant.
-The OAuth client ID is configured explicitly; it is never derived from the SPIFFE ID or pattern. The client ID must not be an absolute URL (a scheme followed by `://`), the same rule the CRD applies, so a hand-written RunConfig cannot set one either. Each association declares its grants in `grant_types`. Each entry is `client_credentials` or `urn:ietf:params:oauth:grant-type:token-exchange`. The list must be non-empty, and an entry may appear only once; an empty or unknown value is rejected. There is no separate per-association `token_exchange` switch, so listing the grant is the only way to enable it. The CRD does not expose `grantTypes` yet: the operator always supplies the token-exchange grant in `buildSPIFFEClientAuthRunConfigs` (`cmd/thv-operator/pkg/controllerutil/authserver.go`), so only a hand-written RunConfig can list `client_credentials`.
+The OAuth client ID is configured explicitly; it is never derived from the SPIFFE ID or pattern. The client ID must not be an absolute URL (a scheme followed by `://`), the same rule the CRD applies, so a hand-written RunConfig cannot set one either. Each association declares its grants in `grant_types` (`grantTypes` in the CRD). Each entry is `client_credentials` or `urn:ietf:params:oauth:grant-type:token-exchange`. The list must be non-empty, and an entry may appear only once; an empty or unknown value is rejected. There is no separate per-association `token_exchange` switch, so listing the grant is the only way to enable it. The CRD field is optional and defaults to `["urn:ietf:params:oauth:grant-type:token-exchange"]`, which is what the operator configured before the field existed, so an association that omits it keeps its previous behavior and `client_credentials` stays opt-in. It is limited to those two values and to at most two items. The operator copies it into the runtime `SPIFFEClientAuthRunConfig.GrantTypes` in `buildSPIFFEClientAuthRunConfigs` (`cmd/thv-operator/pkg/controllerutil/authserver.go`) and uses the same token-exchange default when the list is empty, which happens when the operator is upgraded without the CRDs or an object is built without the API server.
### Resources are the only target list
@@ -85,7 +85,11 @@ Discovery (`grantTypesSupported` and `tokenEndpointAuthMethodsSupported` in `pkg
### Upgrading
-Compared with v0.65.0, every association needs `resources`, and SPIFFE token exchange now uses the resource-only rule above. An association without `resources` (previously allowed for token exchange only) fails validation. The CEL rules reject a CR at admission when it is created, or when its `spiffeClientAuth` list is changed, without `resources`. The list is at `spec.embeddedAuthServer.inboundGrants.spiffeClientAuth` on MCPExternalAuthConfig and `spec.authServerConfig.inboundGrants.spiffeClientAuth` on VirtualMCPServer. On clusters with CRD validation ratcheting (the `CRDValidationRatcheting` feature, on by default since Kubernetes 1.30), an update that leaves that list unchanged is still admitted, including other edits to the auth server config and finalizer removal on delete. The MCPExternalAuthConfig's own `Valid` condition then reports the missing `resources`, and servers that consume it fail to reconcile until it is added. An inline VirtualMCPServer configuration reports it on its `AuthServerConfigValidated` condition. The auth server refuses to start with such a RunConfig. A SPIFFE client that sends `audience=` or no target now gets `invalid_target` instead of a token; it must send one `resource` listed in its association. On a backend that keeps placeholders between runs (Redis), the first start of the new version logs one `configured client replaced with a different policy` WARN for each association. This happens because every placeholder stored by v0.65.0 carries `audiences` (they were required then), and the new placeholder does not. It happens even if you already removed `audiences` from the configuration, since the WARN comes from the stored row, not the current config. Each replica that reads the old row before it is rewritten logs it, and it can repeat if a v0.65.0 replica restarts during the rollout and writes the old row back. Later restarts do not log it, because a nil and an empty `audiences` list compare equal. Nothing is authorized differently by the replacement. Setting `audiences` still validates and is only reported as deprecated.
+Compared with v0.65.0, every association needs `resources`, and SPIFFE token exchange now uses the resource-only rule above. An association without `resources` (previously allowed for token exchange only) fails validation. `grantTypes` needs no change: the API server fills in the token-exchange default for existing associations that do not set it, including objects already stored in etcd, so they keep working as before.
+
+`resources` is enforced by a CEL rule on the association (`resources is required`), not by the schema's required-field check, because Kubernetes does not ratchet required-field errors. The rule rejects a CR at admission when it is created, or when its `spiffeClientAuth` list is changed, without the field. The list is at `spec.embeddedAuthServer.inboundGrants.spiffeClientAuth` on MCPExternalAuthConfig and `spec.authServerConfig.inboundGrants.spiffeClientAuth` on VirtualMCPServer. On clusters with CRD validation ratcheting (the `CRDValidationRatcheting` feature, on by default since Kubernetes 1.30), an update that leaves that list unchanged is still admitted, including other edits to the auth server config and finalizer removal on delete. The MCPExternalAuthConfig's own `Valid` condition then reports the missing `resources`, and servers that consume it fail to reconcile until the field is added. An inline VirtualMCPServer configuration reports the same on its `AuthServerConfigValidated` condition. The auth server refuses to start with such a RunConfig.
+
+Install the new CRDs and the new operator before adding `client_credentials` to any association. An operator from before this change does not know `grantTypes`: it ignores the field and always configures token exchange, so a CR that lists only `client_credentials` would still get token exchange. The `operator-crds` and `operator` Helm charts are separate releases, so nothing enforces this order.
### Trust-bundle source
@@ -128,6 +132,7 @@ spec:
methods: [spiffe_x509]
resources: [https://mcp.example.com]
scopes: [openid]
+ grantTypes: [client_credentials]
```
An association is valid only when it references a declared domain, its `principalPattern` belongs to that domain, and its methods are enabled by that domain. A principal consisting only of a trust domain, such as `spiffe://example.org`, is invalid because it cannot match an SVID. Patterns may be exact or end in `/*`; the domain-wide `spiffe://example.org/*` wildcard remains valid. A wildcard matches descendants at a path boundary only, not its base path or a partial segment. Each pattern and client ID has one owner. Duplicate or overlapping patterns, duplicate client IDs, unknown domains, disabled methods, an unreferenced trust domain, and invalid or incomplete policies all cause validation to fail rather than relying on configuration order.
@@ -196,7 +201,7 @@ A JWT-SVID is a bearer credential, and the SPIFFE path has no application-level
An association counts as a confidential client in the cleartext-transport check (`RunConfig.hasConfidentialClients`, `Config.hasStaticConfidentialClients` and `ValidateConfidentialClientTransport`), as delegate clients do, only when it allows `spiffe_jwt` and also grants `client_credentials`. For such an association `insecure_allow_http` is rejected, and an `http` issuer is accepted only when `insecure_allow_confidential_over_loopback_http` is set and the issuer host is loopback. The check runs in `RunConfig.Validate()` and `Config.Validate()`. An association that enables only `spiffe_x509` does not trigger it, and neither does one that allows `spiffe_jwt` for token exchange only.
-Token-exchange-only JWT-SVID associations are excluded so that existing deployments keep working, not because they are safer. Token exchange over plain HTTP is still exposed. A passive observer captures the JWT-SVID and the subject token from the same request, and can exchange them again for as long as the SVID is valid. Serve the issuer over TLS. The CRD admission rules do not include the `client_credentials` condition yet, because a custom resource cannot list `client_credentials` on this version.
+Token-exchange-only JWT-SVID associations are excluded so that existing deployments keep working, not because they are safer. Token exchange over plain HTTP is still exposed. A passive observer captures the JWT-SVID and the subject token from the same request, and can exchange them again for as long as the SVID is valid. Serve the issuer over TLS. For a custom resource, the same condition applies in two places: the two CRD admission rules for `insecureAllowHTTP` and for `http` issuers (a non-loopback `http` issuer that sets the loopback opt-in passes them and is rejected only by `EmbeddedAuthServerConfig.ValidateInboundGrants` at reconcile), and that Go validation. Both match an association that has `spiffe_jwt` in `methods` and `client_credentials` in `grantTypes`. `grantTypes` is a new field, so the rule rejects no object that existed before it.
With the `client_credentials` grant, each request that presents a replayed SVID mints a new access token. One captured SVID can therefore mint any number of access tokens until it expires, not just one. Each token lives no longer than the SVID that authenticated the request (see "client_credentials requests"), so a replayed SVID mints tokens that expire within its own validity window. Tokens are not bound to the client certificate or key (RFC 8705), and that binding is not implemented. This is accepted behavior: the SPIFFE specification treats JWT-SVIDs as bearer tokens and does not require `jti`.
diff --git a/docs/arch/README.md b/docs/arch/README.md
index fa00b2f272..7d72f01ff5 100644
--- a/docs/arch/README.md
+++ b/docs/arch/README.md
@@ -148,7 +148,7 @@ Welcome to the ToolHive architecture documentation. This directory contains comp
- SPIFFE client authentication is enforced for trust domains with a `file` bundle source; `bundle_endpoint` and `workload_api` fail validation
- Auth-server TLS listener runs on the proxy runner and vMCP at fixed port 8443; the operator configures its certificate (`tlsListener`) and exposes the port
- JWT-SVID and X.509-SVID client authentication (fail closed, certificate leaf profile, no fallback)
- - Per-association `grant_types`: `client_credentials`, token exchange, or both, with the `client_credentials` request rules (exact `resource`, no `audience`, no refresh token)
+ - Per-association `grant_types` (`grantTypes` in the CRD): `client_credentials`, token exchange, or both, with the `client_credentials` request rules (exact `resource`, no `audience`, no refresh token)
- Fail-closed policy validation and durable, restart-safe static-client reservation
- Endpoint/Workload API loading and RFC 8705 discovery metadata remain pending
diff --git a/docs/operator/crd-api.md b/docs/operator/crd-api.md
index f44a25f09f..ed188654e5 100644
--- a/docs/operator/crd-api.md
+++ b/docs/operator/crd-api.md
@@ -2040,8 +2040,9 @@ or accepts token exchange without an interactive authorization flow.
This type is shared by MCPExternalAuthConfig.Spec.EmbeddedAuthServer and
VirtualMCPServer.Spec.AuthServerConfig, so the XValidation rules below are
enforced at admission for both CRDs. CEL only requires the explicit opt-in for
-delegate clients using an HTTP issuer; the shared Go validator performs the
-precise loopback-host security check.
+delegate clients and JWT-SVID SPIFFE client_credentials associations using an
+HTTP issuer; the shared Go validator performs the precise loopback-host
+security check.
The shared Go-level ValidateConfidentialClientTransport validator remains the
source of truth for confidential-client transport and loopback policy,
@@ -2069,11 +2070,11 @@ _Appears in:_
| `primaryUpstreamProvider` _string_ | PrimaryUpstreamProvider names the upstream IDP whose access token Cedar
should read claims from when authorising a request. Must match the name
of one of the entries in UpstreamProviders. When empty, the controller
auto-selects the first entry of UpstreamProviders.
Only meaningful on VirtualMCPServer, where multiple upstream providers
can be configured and Cedar needs to pick which token's claims to
evaluate. The VirtualMCPServer controller validates this field against
UpstreamProviders at admission and rejects unresolvable values.
On MCPServer and MCPRemoteProxy this field is structurally present (the
EmbeddedAuthServerConfig struct is shared) but has no runtime effect:
those CRDs are restricted to a single upstream so there is no choice to
make. Setting it on those CRDs is silently ignored. | | MaxLength: 63
MinLength: 1
Pattern: `^[a-z0-9]([a-z0-9-]*[a-z0-9])?$`
Optional: \{\}
|
| `storage` _[api.v1beta1.AuthServerStorageConfig](#apiv1beta1authserverstorageconfig)_ | Storage configures the storage backend for the embedded auth server.
If not specified, defaults to in-memory storage. | | Optional: \{\}
|
| `disableUpstreamTokenInjection` _boolean_ | DisableUpstreamTokenInjection prevents the embedded auth server from injecting
upstream IdP tokens into requests forwarded to the backend MCP server.
When true, the embedded auth server still handles OAuth flows for clients,
but instead of swapping ToolHive JWTs for upstream tokens the proxy STRIPS
the client's credential headers (Authorization, Cookie, Proxy-Authorization)
after validating the JWT — the backend receives an unauthenticated request.
Use headerForward to attach static credentials (e.g. an API key) if the
backend needs them. Cannot be combined with token exchange, AWS STS, or OBO
middleware, which would re-add credentials after the strip.
This is useful when the backend MCP server does not require authentication
(e.g., public documentation servers) but you still want client authentication. | false | Optional: \{\}
|
-| `insecureAllowHTTP` _boolean_ | InsecureAllowHTTP permits an http:// issuer URL for non-localhost hosts.
Only set this for in-cluster Kubernetes deployments where traffic between
pods traverses a trusted network (e.g. the in-cluster service mesh).
Production deployments reachable outside the cluster MUST use https://.
On VirtualMCPServer: when false (the default), http:// issuers for non-localhost
hosts are rejected at reconcile time with an AuthServerConfigValidated=False condition.
On MCPServer and MCPRemoteProxy (via MCPExternalAuthConfig): this field is
structurally present but enforcement is deferred to pod startup via Config.Validate();
a misconfigured issuer will cause the pod to crash at startup rather than surface
as an operator condition.
One combination is rejected at admission on all three CRDs regardless of the
above: setting this field alongside confidential client registration or
delegate clients, which would issue or use client secrets in cleartext over
an unauthenticated endpoint (see the XValidation rule on
EmbeddedAuthServerConfig). | false | Optional: \{\}
|
+| `insecureAllowHTTP` _boolean_ | InsecureAllowHTTP permits an http:// issuer URL for non-localhost hosts.
Only set this for in-cluster Kubernetes deployments where traffic between
pods traverses a trusted network (e.g. the in-cluster service mesh).
Production deployments reachable outside the cluster MUST use https://.
On VirtualMCPServer: when false (the default), http:// issuers for non-localhost
hosts are rejected at reconcile time with an AuthServerConfigValidated=False condition.
On MCPServer and MCPRemoteProxy (via MCPExternalAuthConfig): this field is
structurally present but enforcement is deferred to pod startup via Config.Validate();
a misconfigured issuer will cause the pod to crash at startup rather than surface
as an operator condition.
One combination is rejected at admission on all three CRDs regardless of the
above: setting this field alongside confidential client registration or
delegate clients, or a SPIFFE association that has spiffe_jwt in methods and
client_credentials in grantTypes on the same association, which would issue
or use client secrets or JWT-SVIDs in cleartext over an unauthenticated
endpoint (see the XValidation rule on
EmbeddedAuthServerConfig). | false | Optional: \{\}
|
| `baselineClientScopes` _string array_ | BaselineClientScopes is a baseline set of OAuth 2.0 scopes guaranteed to be
included in every client registration. The embedded auth server unions these
scopes into the registered set returned by RFC 7591 Dynamic Client
Registration, so a client that narrows the `scope` field at /oauth/register
can still request the baseline scopes at /oauth/authorize. All values must
be present in the upstream-derived scopesSupported set; the auth server
fails to start if any value is missing.
Security: every client registered via /oauth/register will gain the
ability to request these scopes at /oauth/authorize, regardless of what
the client itself requested. Keep the baseline narrow (typically
"openid" and "offline_access"). Adding a privileged scope here — e.g.
"admin:read" — would grant it to every DCR-registered client, including
public clients like Claude Code, Cursor, and VS Code.
When cimd.enabled is true, every dynamically resolved CIMD client will
also gain the ability to request these scopes, including third-party
clients resolved from arbitrary HTTPS URLs. | | MaxItems: 10
items:MinLength: 1
items:Pattern: `^[\x21\x23-\x5B\x5D-\x7E]+$`
Optional: \{\}
|
| `allowConfidentialClientRegistration` _boolean_ | AllowConfidentialClientRegistration permits RFC 7591 Dynamic Client
Registration of confidential clients: when true, /oauth/register
accepts token_endpoint_auth_method values client_secret_basic and
client_secret_post in addition to "none" (still the default on
omission) and mints a client_secret returned exactly once.
Confidential registrations are restricted to https non-loopback
redirect URIs, and on the Redis storage backend all DCR-issued
registrations are evicted after 30 days of inactivity and must
re-register. This gates registration only: disabling it does not
revoke or reject already-minted secrets at the token endpoint.
Security: registration is unauthenticated, so enabling this lets any
caller who can reach the endpoint obtain a client credential.
Combining it with insecureAllowHTTP is rejected at validation. | false | Optional: \{\}
|
| `allowPrivateKeyJWTRegistration` _boolean_ | AllowPrivateKeyJWTRegistration permits Dynamic Client Registration of
clients using private_key_jwt authentication. Registration behavior is
intentionally configured separately from confidential-client registration.
Security: registration is unauthenticated, so enabling this lets any
caller who can reach the endpoint register a private_key_jwt client.
Unlike allowConfidentialClientRegistration, this is NOT rejected when
combined with insecureAllowHTTP: registration never returns a secret
for a private_key_jwt client, so there is nothing for cleartext HTTP
to expose. | false | Optional: \{\}
|
-| `insecureAllowConfidentialOverLoopbackHTTP` _boolean_ | InsecureAllowConfidentialOverLoopbackHTTP opts in to confidential
Dynamic Client Registration (DCR) and delegate clients when issuer is a
plain-HTTP loopback URL (e.g. "http://localhost:8080"). Without this
flag, that combination is rejected at reconcile time: a loopback http://
issuer is normally fine for local development since the traffic never
leaves the machine, but confidential clients send secrets over cleartext.
Forcing TLS onto every loopback deployment instead would just push
operators toward insecureAllowHTTP, which is worse: that also disables
the non-loopback host check. Has no effect when there are no confidential
clients or issuer is https.
private_key_jwt registration has no equivalent flag or transport
restriction: unlike confidential registration, it never returns a
client_secret (or any other secret) in the DCR response, so there is
nothing here for cleartext HTTP to expose. | false | Optional: \{\}
|
+| `insecureAllowConfidentialOverLoopbackHTTP` _boolean_ | InsecureAllowConfidentialOverLoopbackHTTP opts in to confidential
Dynamic Client Registration (DCR), delegate clients and SPIFFE
associations that have spiffe_jwt in methods and client_credentials in
grantTypes on the same association, when issuer is a plain-HTTP loopback
URL (e.g. "http://localhost:8080"). Without this
flag, that combination is rejected at admission, and reconcile additionally
requires the issuer host to be loopback. A loopback http://
issuer is normally fine for local development since the traffic never
leaves the machine, but confidential clients send secrets over cleartext.
Forcing TLS onto every loopback deployment instead would just push
operators toward insecureAllowHTTP, which is worse: that also disables
the non-loopback host check. Has no effect when there are no confidential
clients or issuer is https.
private_key_jwt registration has no equivalent flag or transport
restriction: unlike confidential registration, it never returns a
client_secret (or any other secret) in the DCR response, so there is
nothing here for cleartext HTTP to expose. | false | Optional: \{\}
|
| `delegateClients` _[api.v1beta1.DelegateClientConfig](#apiv1beta1delegateclientconfig) array_ | DelegateClients configures pre-provisioned confidential clients for RFC 8693
token exchange. Each secret is referenced from a Kubernetes Secret; no
plaintext secret, redirect URI, or grant selection is accepted here. The
operator always supplies the token-exchange grant when it converts this
configuration to the runtime contract.
This is independent of allowConfidentialClientRegistration: it neither
enables nor requires unauthenticated confidential dynamic client
registration.
This legacy field is deprecated; use inboundGrants.tokenExchange.delegateClients. | | MaxItems: 10
Optional: \{\}
|
| `trustedIssuers` _[api.v1beta1.TrustedIssuerConfig](#apiv1beta1trustedissuerconfig) array_ | TrustedIssuers configures external OIDC issuers whose tokens are
accepted as RFC 8693 subject tokens during token exchange, in addition
to self-issued subject tokens. Empty (the default) means only
self-issued subject tokens are accepted. See
docs/arch/17-token-exchange-delegation.md for the trust model. | | MaxItems: 20
Optional: \{\}
|
| `forceConfidentialRedirectUris` _string array_ | ForceConfidentialRedirectURIs lists redirect URIs that must be
registered as confidential clients regardless of the
token_endpoint_auth_method the DCR request declares. A registration
whose redirectUris contains an EXACT match for one of these entries is
issued a real client_secret and reported back as
token_endpoint_auth_method "client_secret_post", even if the request
said "none" or omitted the field.
Intended for MCP clients that declare themselves public
(token_endpoint_auth_method: "none") per RFC 7591 but then refuse to
proceed because the response carries no client_secret — a
self-contradictory request. RFC 7591 §3.2.1 permits the server to
substitute client metadata, so this takes such a client at its word
that it wants a secret. Remove an entry once the client is fixed to
handle "none" registrations correctly.
Exact matching is deliberate: an attacker who registers with someone
else's callback URI is issued a secret for a client whose
authorization codes are delivered to that someone else's redirect
endpoint, not to the attacker, so this is not a way to obtain a usable
credential for another client.
Requires allowConfidentialClientRegistration to be true. Every entry
must be an https non-loopback URI — a loopback client is a public
client by construction (OAuth 2.1 §2.1) and must not be issued a
secret; this is enforced at reconcile time since CEL cannot express
the loopback-hostname check. | | MaxItems: 10
items:Pattern: `^https://[^\s?#]+$`
Optional: \{\}
|
@@ -4354,9 +4355,6 @@ authenticate with a JWT-SVID or an X.509-SVID and have no client secret.
Trust material comes from the declared bundle source (see
SPIFFETrustDomainConfig's doc comment).
-The CRD does not expose grantTypes. The converter always supplies the
-RFC 8693 token-exchange grant instead of letting it be configured.
-
_Appears in:_
@@ -4368,9 +4366,10 @@ _Appears in:_
| `principalPattern` _string_ | PrincipalPattern is a concrete SPIFFE ID or a terminal /* pattern within
the declared trust domain. This pattern is a best-effort CRD-level
approximation; runtime parsing via spiffeid.FromString remains
authoritative. | | MaxLength: 2048
Pattern: `^spiffe://[a-z0-9._-]+((/[a-zA-Z0-9._-]+)+(/\*)?\|/\*)$`
Required: \{\}
|
| `clientId` _string_ | ClientID is the explicit OAuth client_id. It is never derived from a
SPIFFE ID. | | MaxLength: 253
MinLength: 1
Required: \{\}
|
| `methods` _[api.v1beta1.SPIFFEAuthenticationMethod](#apiv1beta1spiffeauthenticationmethod) array_ | Methods are the credential types this association may authenticate
with. Must be a subset of the referenced trust domain's methods. | | MaxItems: 2
MinItems: 1
Required: \{\}
items:Enum: [spiffe_x509 spiffe_jwt]
|
-| `resources` _string array_ | Resources are RFC 8707 resource indicators this association may
request. Must be a subset of the server's allowed_audiences allowlist,
which is derived at reconcile time and not available on this CRD, so
allowlist membership is validated at reconcile time, not admission.
Shape (a well-formed absolute HTTP(S) URI) is independent of that
derived allowlist and is validated here. Required, with at least one
entry, for every association: token exchange takes exactly one resource
per request and grants it as the token audience. | | MaxItems: 50
items:MaxLength: 2048
items:MinLength: 1
items:Pattern: `^https?://[^@#[:space:]]+$`
Optional: \{\}
|
+| `resources` _string array_ | Resources are RFC 8707 resource indicators this association may
request. Must be a subset of the server's allowed_audiences allowlist,
which is derived at reconcile time and not available on this CRD, so
allowlist membership is validated at reconcile time, not admission.
Shape (a well-formed absolute HTTP(S) URI) is independent of that
derived allowlist and is validated here. Required, with at least one
entry, for every association: client_credentials and token exchange each
take exactly one resource per request and grant it as the token
audience. | | MaxItems: 50
items:MaxLength: 2048
items:MinLength: 1
items:Pattern: `^https?://[^@#[:space:]]+$`
Optional: \{\}
|
| `audiences` _string array_ | Deprecated: ignored; use resources.
The field was required in earlier releases and is still accepted so
existing objects keep validating. A non-empty value is reported by the
DeprecatedInboundGrantConfiguration condition and has no effect on token
targeting. | | MaxItems: 50
items:MaxLength: 2048
items:MinLength: 1
Optional: \{\}
|
| `scopes` _string array_ | Scopes are OAuth scopes granted to this association. Must be a subset
of the server's effective supported scopes. | | MaxItems: 50
MinItems: 1
Required: \{\}
items:MaxLength: 256
items:MinLength: 1
|
+| `grantTypes` _string array_ | GrantTypes contains the OAuth grants permitted for this association.
It defaults to the token-exchange grant when omitted, which is what the
operator configured before this field existed. List client_credentials
to opt in to the SPIFFE-bound client credentials grant. The list alone
decides which grants the association may use: client authentication does
not confer any grant, and there is no separate per-grant enable switch.
Use urn:ietf:params:oauth:grant-type:token-exchange for RFC 8693 token
exchange. | [urn:ietf:params:oauth:grant-type:token-exchange] | MaxItems: 2
MinItems: 1
items:Enum: [client_credentials urn:ietf:params:oauth:grant-type:token-exchange]
Optional: \{\}
|
#### api.v1beta1.SPIFFEFileBundleSourceConfig