Repository navigation
Description
Problem
Access tokens issued by the embedded authorization server carry the JOSE header typ: JWT, fosite's default (token/jwt/token.go, JWTHeaderTypeValue). ToolHive never sets typ on the access-token session header.
RFC 9068 §2.1 says JWT access tokens MUST be typed at+jwt (application/at+jwt is also allowed), and §4 says resource servers MUST check it. The type is what lets a resource server refuse another JWT from the same issuer and audience as an access token: an ID token, an ID-JAG, or a client assertion.
This now matters for two reasons:
- The authorization server will issue a second kind of JWT under the same issuer: ID-JAGs (ID-JAG issuance through token exchange #6898 "ID-JAG issuance through token exchange"), typed
oauth-id-jag+jwt. Typing access tokens makes the two distinguishable by header, not only by audience. - Resource servers that apply RFC 9068 strictly reject ToolHive's access tokens. Mecatl, which embeds this authorization server as its sign-in server, refuses access tokens for its API that are not typed
at+jwt, so a real deployment fails at sign-in.
Change
- A setting for the access-token
typ:JWT(today) orat+jwt. Whenat+jwtis set, every JWT access token the server issues carries it: authorization code, refresh, client credentials, token exchange, and JWT-bearer / ID-JAG redemption. - Other token types keep their
typ: ID-JAGs stayoauth-id-jag+jwt. - ToolHive's own consumers accept both values: the token validator in
pkg/authand the vMCP. They do not checktyptoday, so this is a test, not a change. The JWT-bearer assertion check (jwt_bearer_handler.go, accepts empty,JWT, oroauth-id-jag+jwt) keeps refusing access tokens presented as assertions,at+jwtincluded.
Default
Proposal: ship the setting with JWT as the default, so existing third-party resource servers are unaffected, and switch the default to at+jwt in a later release with a release note. Most JWT libraries ignore typ unless configured to check it, but some default type verifiers accept only JWT or no typ, so a resource server that validates ToolHive tokens directly could start rejecting them. If maintainers prefer, at+jwt by default from the start is the RFC 9068 behaviour.
Acceptance
- With
at+jwtset, an access token from each grant above has headertyp: at+jwt; with the default, behaviour is unchanged. - ID-JAGs keep
typ: oauth-id-jag+jwt. - ToolHive's token validator and the vMCP accept access tokens with either
typ. - An access token presented as a JWT-bearer assertion is still refused.
- Tests decode the header, not only the claims.
Not in scope
Enforcing typ on the consuming side (a resource server in ToolHive refusing an untyped access token from its own issuer). That is a separate decision once issuing at+jwt is the default.
Related
- Emit sub_id (RFC 9493) with the user's upstream identity in access tokens #6900 "Emit sub_id (RFC 9493) with the user's upstream identity in access tokens" (merged): the same consumer checks both.
- Part of Authorization server: revocation and audit for delegated agents #6886 "Authorization server: refresh tokens and ID-JAG issuance for delegated agents".
Activity