Repository navigation
Description
Description
Implement the spiffe_x509 client-authentication method: a workload presents
its X.509-SVID on a mutually authenticated TLS connection, and the
authorization server authenticates the OAuth client from the verified
certificate instead of from a shared secret.
This is the path the spiffee-authserver branch proved out, and the reason
#6082 called option D the strongest answer for Kubernetes: there is no secret
to create, mount, rotate or revoke, and the client ID is the SPIFFE ID, so it
is knowable before the workload ever connects.
Scope
- Add TLS and optional mutual-TLS listener support to the relevant proxy
transports. - Validate X.509-SVID chains against the configured trust-domain bundle from
sub-issue 2. - Extract the SPIFFE ID from the certificate and resolve it through the shared
client-association policy from sub-issue 1. - Require an explicit
client_idassociated with the presented SPIFFE ID. - Advertise
spiffe_x509only when the method is fully configured and
operational. - Keep authorization-server certificate validation separate from SPIFFE workload
certificate validation — the AS's own WebPKI trust is not the workload trust
bundle.
Prior art
The branch implemented this as a custom fosite.ClientAuthenticationStrategy
that authenticates from a verified X.509-SVID and delegates to the default
strategy when no SPIFFE ID is present, which is what leaves browser and
public-client flows untouched. Clients auto-register just-in-time with
Public: false and no secret, enabled by a three-line seam in shared code
(registration.Config.SkipSecretHash).
Fail-closed was verified on the branch: a caller presenting
client_id=spiffe://… without a client certificate falls through to the
default strategy and fails there. The public-client rejection was not relaxed.
Preserve both properties.
Two weaknesses on the branch must be fixed, not carried: a nil policy meant
allow-all, and auto-registered clients received every supported scope and every
allowed audience. Per-identity narrowing comes from sub-issue 1's association
policy.
Acceptance criteria
Certificate shape:
- The certificate is a leaf certificate with
CA=false. - The certificate has the
digitalSignaturekey-usage bit. - The certificate has exactly one URI SAN containing a valid, non-root SPIFFE
ID. Additional DNS SANs are allowed; additional URI SANs are rejected. - The chain validates against the configured trust-domain bundle.
Client resolution:
- The request contains an explicit
client_idassociated with the certificate's
SPIFFE ID.
Fail-closed:
- A missing certificate cannot produce a SPIFFE-authenticated principal.
- A malformed or unauthorized certificate cannot fall back to public or
secret-based client authentication. - Existing authorization-code and browser flows continue to work where
configured.
Dependencies
- Sub-issue 1 (identity, association and configuration model)
- Sub-issue 2 (trust-domain bundle management) — for chain validation material
Can proceed in parallel with the JWT-SVID sub-issue once both foundations exist.
Coordination with the sibling credential type
#6202 and #6203 replace the same fosite hook: a single
ClientAuthenticationStrategy
(func(context.Context, *http.Request, url.Values) (fosite.Client, error)).
#6202 dispatches on a SPIFFE ID placed in the request context by the mTLS
listener; #6203 dispatches on client_assertion_type in the request form.
That dispatch is introduced once, separately, as a no-behaviour-change change
before either issue starts — both SPIFFE arms stubbed, everything else falling
through to fosite's default strategy. This issue owns one arm only and must
not modify the dispatch itself. A needed change there goes back to the shared
change rather than being patched in place.
Two things to know when filling in an arm:
- Fosite's default strategy already dispatches on
client_assertion_typefor
RFC 7523urn:ietf:params:oauth:client-assertion-type:jwt-bearer. The SPIFFE
assertion type is different and must be matched exactly, or existing
private-key-JWT client authentication breaks. - Both arms resolve through
SPIFFEAssociationRegistry.Resolvefrom sub-issue
1, which already fails closed on unknown association, wrong client ID, and
disabled method. Do not add a parallel lookup — that registry is what makes
the "equivalent authorization outcome" guarantee enforceable rather than
merely tested.
Related
- Part of the SPIFFE client-authentication epic
- Token-exchange grant is unreachable: no way to provision a confidential client #6082 (option D)
Activity
jhrozek commentedon Aug 13, 2026
Reuse from the
spiffee-authserverbranch: high, roughly 1650 lines including tests.pkg/authserver/spiffe/context.gois the piece to keep as-is. Identity lands in a context key rather than a certificate-shaped struct, which is what lets the JWT path in #6203 produce the same principal without touching downstream code.Lift the shape and the tests, but not the trust logic:
middleware.godoes not validate the chain. It readsr.TLS.PeerCertificates[0]and delegates verification entirely to the listener'sClientCAswithClientAuth: VerifyClientCertIfGiven. That is exactly what Implement SPIFFE trust-domain bundle management and rotation #6201 replaces.policy.gohardcodes the Kubernetes/ns/<ns>/sa/<sa>convention and denies any other SPIFFE path. Superseded by the association registry from Define the SPIFFE client identity, association, and configuration model #6200.strategy.goauto-registers clients on first contact with all supported scopes and audiences. Superseded by the static client overlay from Define the SPIFFE client identity, association, and configuration model #6200, and one of the two weaknesses the epic warns against.Worth keeping from
middleware.go: it requires exactly onespiffe://URI SAN, ignores non-SPIFFE URIs for cert-manager compatibility, and does a path-traversal check on the SPIFFE ID path.Tests are the real prize:
middleware_test.go(282),policy_test.go(254),strategy_test.go(227),context_test.go.Add SPIFFE client authentication dispatch (#6562)
Add TLS/mTLS listener support for SPIFFE X.509 auth
Add TLS/mTLS listener support for SPIFFE X.509 auth
jhrozek commentedon Oct 21, 2026
Merged so far, none of it verifying a certificate yet:
The X.509 verification arm is not merged.
Authenticate clients with SPIFFE X.509-SVIDs
Authenticate clients with SPIFFE X.509-SVIDs
Authenticate clients with SPIFFE X.509-SVIDs
Authenticate clients with SPIFFE X.509-SVIDs
Authenticate clients with SPIFFE X.509-SVIDs (#7092)
jhrozek commentedon Nov 24, 2026
Closing as done. It landed in #6843 (TLS listener and middleware), #7092 (X.509-SVID client auth) and #7150.
Leaf checks are in
verifySPIFFEX509. It requiresdigitalSignatureand a critical key-usage extension, valid basic-constraints and SAN extensions, a non-root canonical SPIFFE ID path, and server plus client auth if an extended-key-usage extension is present.x509svid.Verifythen validates the chain against the bundle for the leaf's trust domain. It rejects a CA leaf and any leaf without exactly one URI SAN.A missing or malformed certificate never falls back to public or secret authentication. A request that mixes in Basic,
client_secretor aclient_assertionis refused. The client is resolved through the shared association registry, so an unknown association, wrongclient_idor disabled method fails closed. The auth server's own WebPKI trust is kept separate from the workload bundle. Discovery advertisesspiffe_x509only when an association enables it.#7194 covers this against SPIRE-issued credentials, including a self-signed certificate that carries the registered SPIFFE ID, which is rejected.