Skip to content

Implement JWT-SVID OAuth client authentication (spiffe_jwt) #6203

Done

Description

@jhrozek

Description

Implement the spiffe_jwt client-authentication method: a workload presents a
JWT-SVID as an OAuth client assertion, and the authorization server
authenticates the client from the validated assertion.

This must work independently of the TLS peer-certificate path. Deployments
that terminate TLS at an ingress cannot present a client certificate to the
authorization server at all, so JWT-SVID is not a convenience alternative to
spiffe_x509 — it is the only SPIFFE option in a large class of real
deployments.

The dominant risk here is type confusion. A JWT-SVID, an OIDC ID token and an
ordinary access token are all signed JWTs, and the same IdP may sign several of
them. Accepting the wrong one as a client assertion would let any bearer of a
routine token authenticate as the workload.

Scope

  • Accept exactly one client_assertion with
    client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-spiffe.
  • Validate JWT-SVID signatures using only the jwt-svid keys of the configured
    trust-domain bundle from sub-issue 2.
  • Extract the SPIFFE ID from sub and resolve it through the shared
    client-association policy from sub-issue 1.
  • Enforce assertion size, cardinality, algorithm, expiry and clock-skew limits.
  • Advertise spiffe_jwt only when the method is fully configured and
    operational.

Acceptance criteria

Assertion acceptance:

  • client_assertion_type matches
    urn:ietf:params:oauth:client-assertion-type:jwt-spiffe exactly.
  • The request contains exactly one JWT-SVID assertion.
  • sub is a valid SPIFFE ID associated with the requested OAuth client.
  • exp is present and valid.
  • aud contains the ToolHive authorization-server issuer as its sole value.
  • The signature validates using only permitted jwt-svid keys from the
    associated trust-domain bundle.

Rejection:

  • Ordinary OIDC access tokens, ID tokens and generic signed JWTs are rejected.
  • Wrong audiences, trust domains, keys, algorithms and client associations are
    rejected.
  • A malformed or unauthorized assertion cannot fall back to public or
    secret-based client authentication.

Hygiene:

  • Assertions and their claims are never written to logs.

Reuse

Signature verification and key resolution come from sub-issue 2's bundle
registry, restricted to the bundle's jwt-svid keys. Use
jwtsvid.ParseAndValidate(token, jwtBundleSource, audience) from go-spiffe/v2
— it consumes the jwtbundle.Source #6201 produces. This issue adds the
SVID-specific claim rules and the type-confusion defences, not a validation
stack.

Also lift pkg/authserver/spiffe/context.go from the spiffee-authserver
branch (26 lines). Identity lands in a context key rather than a
certificate-shaped struct, which is what lets this issue produce the same
principal as #6202 without touching downstream code.

Correction to the original text: this issue previously named
pkg/oauthproto/jwks.go as the source of signature verification. That is wrong
twice over. SPIFFE JWT authorities come from the trust bundle, not from a JWKS
URI, so jwtsvid.ParseAndValidate makes no HTTP request and no fetcher is
involved. And that file is an unpushed spike artifact that should not be adopted
— see #6319 for the separate JWKS consolidation work.

Dependencies

  • Sub-issue 1 (identity, association and configuration model)
  • Sub-issue 2 (trust-domain bundle management) — specifically its jwt-svid
    key restriction

Can proceed in parallel with the X.509-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_type for
    RFC 7523 urn: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.Resolve from 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

Activity

  1. added
    enhancement
    on Aug 5, 2026
  2. added
    go
    on Aug 5, 2026
  3. added
    needs-triage
    on Aug 5, 2026
  4. removed
    needs-triage
    on Aug 5, 2026
  5. jhrozek commented on Aug 13, 2026

    @jhrozek
    ContributorAuthor

    Reuse from the spiffee-authserver branch: low on code, useful on design.

    There is no JWT-SVID code on the branch. No jwtsvid, no jwtbundle, no JWT authority handling anywhere. Only X.509 SAN extraction.

    The thing that does carry over is pkg/authserver/spiffe/context.go. Because the X.509 path stores identity in a context key rather than a certificate struct, the JWT path can write the same key and everything downstream is unchanged. That is the "both methods resolve to the same principal" requirement, already designed rather than merely asserted.

    docs/spiffe-poc/future-directions.md sketches the flow: validate the assertion against the bundle's JWT authority keys, take the SPIFFE ID from sub, reuse ContextWithSPIFFEID, and disambiguate from ordinary OIDC bearer tokens using client_assertion_type. It also flags that the trust bundle needs JWT authority keys alongside the X.509 roots, which is #6201's job.

  6. self-assigned this
    on Aug 14, 2026
  7. jhrozek commented on Oct 21, 2026

    @jhrozek
    ContributorAuthor

    Merged so far: #6562 (9fe5c43) adds the dispatch and #6563 (9171b32) implements the JWT-SVID arm. Config that enables SPIFFE trust domains is still rejected at startup, so the method can't be turned on from main yet.

  8. jhrozek commented on Nov 24, 2026

    @jhrozek
    ContributorAuthor

    Closing as done (#6563, with the shared dispatch in #6562).

    It matches the exact jwt-spiffe assertion type and requires one assertion and one client_id. Duplicates are refused, and so is mixing in Basic or a client_secret. It rejects an assertion over 16 KiB or valid for more than the allowed remaining lifetime. It validates through jwtsvid.ParseAndValidate against the trust-domain bundle, requires the issuer as the only audience, and resolves through the shared association registry. Assertions are not logged. Plain RFC 7523 jwt-bearer assertions still go to fosite's default strategy.

    Unit tests cover wrong signature, missing key ID, invalid typ, wrong and multiple audiences, expired, wrong trust domain, and algorithm handling. #7194 covers a wrong key under a known key ID and rotation against real SPIRE. There is no test that feeds in an actual OIDC ID token or access token. Type confusion is handled by the exact assertion type, the typ check and the sole-audience rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

authenticationauthorizationenhancementgo

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions