Skip to content

Set typ: at+jwt on access tokens issued by the embedded authorization server (RFC 9068) #6941

Closed

Description

@jhrozek

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) or at+jwt. When at+jwt is 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 stay oauth-id-jag+jwt.
  • ToolHive's own consumers accept both values: the token validator in pkg/auth and the vMCP. They do not check typ today, so this is a test, not a change. The JWT-bearer assertion check (jwt_bearer_handler.go, accepts empty, JWT, or oauth-id-jag+jwt) keeps refusing access tokens presented as assertions, at+jwt included.

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+jwt set, an access token from each grant above has header typ: 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

Metadata

Metadata

Assignees

Labels

needs-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions