Skip to content

Embedded auth server: bound JWT-bearer handler for ID-JAG assertions #6676

Closed

Description

@aron-muon

Description

The embedded authorization server's RFC 7523 JWT-bearer grant is deliberately unbound-only. JWTBearerHandler.CanHandleTokenEndpointRequest refuses any assertion whose JOSE typ is oauth-id-jag+jwt:

// CanHandleTokenEndpointRequest only claims plain assertions. A recognized ID-JAG
// assertion is intentionally left for a future bound handler; malformed and
// unsupported typ values remain this handler's responsibility to reject.

(pkg/authserver/server/tokenexchange/jwt_bearer_handler.go)

That future bound handler does not exist and no issue tracks it. The result: ToolHive can request ID-JAGs (the vMCP XAA outgoing strategy from #5218 / #5684) but the embedded AS cannot accept one. A ToolHive-fronted MCP server cannot be the resource side of Identity Assertion Authorization Grant (draft-ietf-oauth-identity-assertion-authz-grant) — which is exactly the position it is in when an IdP like Okta federates agent access to it via Cross App Access.

Since no handler claims the grant, the observable failure is fosite's generic invalid_request ("...redirect_uri..." boilerplate) for every parameter variant, which took a while to diagnose. Until the bound handler exists, a recognized-but-unsupported typ arguably deserves a clearer rejection, but the real fix is to support it.

Reproduction against a live Okta org (2026-09-17)

Full E2E with Okta for AI Agents (org on OK10, build 2026.09.0 E) against a deployed toolhive AS (commit 9208d07, also current main):

  1. Okta side: AI agent with a linked OIDC app; a resource app whose per-app Resource Server → Cross-app access connector is enabled with issuer + audience = the toolhive AS issuer URL; resource connection on the agent with resource indicator = the MCP resource URI and the agent's client ID at the toolhive AS (a DCR-registered public client).
  2. Authorization-code login → id_token.
  3. RFC 8693 exchange at the Okta org AS (/oauth2/v1/token, requested_token_type=urn:ietf:params:oauth:token-type:id-jag) — works. Resulting JAG: typ: oauth-id-jag+jwt, iss = the Okta org, sub = the delegating user, aud + aud_tenant = the toolhive AS issuer URL, act.sub = the Okta agent's own client ID (sub_profile: ai_agent web_app), client_id = the agent's DCR client ID at the toolhive AS, 300 s TTL, single-use jti.
  4. RFC 7523 redemption at the toolhive AS (grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer, assertion=<JAG>, exactly one resource, client_id of the DCR client): fosite generic invalid_request — no handler claims the grant.

The AS was configured with a trusted issuer for the Okta org and an inbound_grants.jwt_bearer.issuer_policies entry (max_assertion_age: 5m, accepted_audiences containing the issuer URL, a subject binding for the user's Okta sub → the MCP resource). Everything up to handler selection is already in place; only the handler is missing.

Design sketch

A second fosite.TokenEndpointHandler in pkg/authserver/server/tokenexchange, claiming exactly the assertions the unbound handler rejects (typ == oauth-id-jag+jwt; the typ split keeps the two handlers mutually exclusive per request):

  • Bound = client authentication is never skipped. CanSkipClientAuth returns false, so fosite's NewAccessRequest requires AuthenticateClient to have succeeded — full auth for confidential clients, client_id identification for public ones. The handler then enforces draft §4.4.1 continuity: the JAG's client_id claim must equal the authenticated client's ID.
  • jti required (the draft requires it for ID-JAGs, unlike plain §2.1 assertions); replay via the existing storage.AssertionJWTConsumer, under a distinct purpose.
  • Reuse everything else: MultiIssuerTokenValidator.ValidateJWTBearerAssertion (JWKS verification, trusted-issuer gate, accepted_audiences intersection — Okta sets the JAG aud from the resource connection's Audience field), validateJWTBearerPolicy (max assertion age, exactly-one-resource, subject bindings), and the same per-issuer inbound_grants.jwt_bearer.issuer_policies config — no new config surface.
  • Issued token: bounded by the assertion's remaining lifetime like the unbound path; carries NoUpstreamSessionClaimKey (a JAG conveys no upstream vendor session, same as a plain assertion); the request's real client, no synthetic client; and the JAG's act claim copied through so the agent identity stays auditable in the issued token (RFC 8693 §4.1 semantics).
  • ID-JAG-specific claims otherwise (aud_tenant, sub_profile, email) ride through ValidatedClaims.Extra untouched.

Open questions

  1. Confidential vs public redeeming clients. Draft §9.1 RECOMMENDS confidential clients. But the clients that exist in practice at a toolhive AS are DCR-registered public ones (nothing can provision a confidential client today — Token-exchange grant is unreachable: no way to provision a confidential client #6082, and the same deployment reality as the unbound handler's clientless argument in Accept third-party JWT assertions as an authorization grant #6336). Proposal: accept public clients with client_id continuity — the assertion itself is the primary credential (single-use jti, ≤ max_assertion_age, audience-pinned), and the binding the draft actually mandates is §4.4.1 client_id match, which works for both client types.
  2. Client grant_types metadata. DCR currently rejects urn:ietf:params:oauth:grant-type:jwt-bearer in grant_types. On an open-DCR server, self-asserted metadata is not a security signal, so the sketch does not gate on it — the per-issuer policy plus the JAG's admin-configured client_id binding are the authorization. Alternative is to allow the value in DCR and enforce it; happy to go either way.
  3. Should the recognized-but-unsupported window (typ recognized, handler absent) return a specific unsupported_grant_type/hint instead of fosite's generic invalid_request? Moot once the handler lands, but relevant for servers configured without it.

We have this working end to end against the Okta org above except for the missing handler, and will follow up with a PR implementing the sketch.

Activity

  1. added
    needs-triage
    on Sep 17, 2026
  2. removed
    needs-triage
    on Sep 17, 2026
  3. jhrozek commented on Sep 17, 2026

    @jhrozek
    Contributor

    thanks a lot for the PR!

    To answer your questions:

    Open questions
    Confidential vs public redeeming clients. Draft §9.1 RECOMMENDS confidential clients. But the clients that exist in practice at a toolhive AS are DCR-registered public ones (nothing can provision a confidential client today — #6082, and the same deployment reality as the unbound handler's clientless argument in #6336). Proposal: accept public clients with client_id continuity — the assertion itself is the primary credential (single-use jti, ≤ max_assertion_age, audience-pinned), and the binding the draft actually mandates is §4.4.1 client_id match, which works for both client types.

    confidential client registration exists now (AllowConfidentialClientRegistration, private_key_jwt DCR, DelegateClientRunConfig). But we should extend the allow list and DelegateClientRunConfig so that a confidential client can actually be provisioned for this grant.

    Client grant_types metadata. DCR currently rejects urn:ietf:params:oauth:grant-type:jwt-bearer in grant_types. On an open-DCR server, self-asserted metadata is not a security signal, so the sketch does not gate on it — the per-issuer policy plus the JAG's admin-configured client_id binding are the authorization. Alternative is to allow the value in DCR and enforce it; happy to go either way.

    I think this is fine for now and can be a follow-up

    Should the recognized-but-unsupported window (typ recognized, handler absent) return a specific unsupported_grant_type/hint instead of fosite's generic invalid_request? Moot once the handler lands, but relevant for servers configured without it.

    I wouldn't over-rotate on this.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions