Repository navigation
Description
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):
- 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).
- Authorization-code login →
id_token. - 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-usejti. - RFC 7523 redemption at the toolhive AS (
grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer,assertion=<JAG>, exactly oneresource,client_idof the DCR client): fosite genericinvalid_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.
CanSkipClientAuthreturns false, so fosite'sNewAccessRequestrequiresAuthenticateClientto have succeeded — full auth for confidential clients, client_id identification for public ones. The handler then enforces draft §4.4.1 continuity: the JAG'sclient_idclaim must equal the authenticated client's ID. jtirequired (the draft requires it for ID-JAGs, unlike plain §2.1 assertions); replay via the existingstorage.AssertionJWTConsumer, under a distinct purpose.- Reuse everything else:
MultiIssuerTokenValidator.ValidateJWTBearerAssertion(JWKS verification, trusted-issuer gate,accepted_audiencesintersection — Okta sets the JAGaudfrom the resource connection's Audience field),validateJWTBearerPolicy(max assertion age, exactly-one-resource, subject bindings), and the same per-issuerinbound_grants.jwt_bearer.issuer_policiesconfig — 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'sactclaim 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 throughValidatedClaims.Extrauntouched.
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 — 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_idcontinuity — the assertion itself is the primary credential (single-usejti, ≤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. - Client
grant_typesmetadata. DCR currently rejectsurn:ietf:params:oauth:grant-type:jwt-beareringrant_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-configuredclient_idbinding are the authorization. Alternative is to allow the value in DCR and enforce it; happy to go either way. - Should the recognized-but-unsupported window (
typrecognized, handler absent) return a specificunsupported_grant_type/hint instead of fosite's genericinvalid_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
jhrozek commentedon Sep 17, 2026
thanks a lot for the PR!
To answer your questions:
confidential client registration exists now (AllowConfidentialClientRegistration, private_key_jwt DCR, DelegateClientRunConfig). But we should extend the allow list and
DelegateClientRunConfigso that a confidential client can actually be provisioned for this grant.I think this is fine for now and can be a follow-up
I wouldn't over-rotate on this.