Repository navigation
Description
Part of #6886. Depends on #6897 (grants through token exchange).
Problem: ToolHive only redeems ID-JAGs. A delegated client needs to request an ID-JAG for a gateway that has its own authorization server, using a grant it holds.
Change:
-
Token exchange with
subject_token_type=refresh_tokenandrequested_token_type=urn:ietf:params:oauth:token-type:id-jag(required). It is handled by Refresh tokens through token exchange, as generic grants #6897's refresh-token handler, whose routing already claims this combination and refuses it today. -
The subject token is a grant from Refresh tokens through token exchange, as generic grants #6897:
- it is for the authenticated client and lists
id-jag; - it is not revoked and not expired;
- if it has a parent, the parent exists and is not revoked. This is checked on every request.
Refusals:
revoked,parent_revoked, ornot_issuable(a grant that listsrefresh_token). A forged, unknown, expired or other-client token gets the one codegrant_invalid, as on the derive path.Three handler changes are needed: allow refresh token to ID-JAG in the routing decision; split the combined depth-and-type check so a child grant can issue ID-JAGs; and give the ID-JAG branch its own request-parameter check. The derive path's
checkRefreshTokenParamsrefusesaudienceandresourcewithinvalid_target, but draft §4.3 makesaudienceREQUIRED for an ID-JAG request (resourceis OPTIONAL). - it is for the authenticated client and lists
-
Targets come from client configuration, not the grant. A grant carries no target bound.
audiencemust be one of the target authorization servers configured for the client, andresourcea resource configured for that target; otherwiseinvalid_target. The configuration may not name this server itself (draft §9.3). The ID-JAG'sclient_idis the client's ID at the target server, from configuration. -
ID-JAG claims and header follow draft-ietf-oauth-identity-assertion-authz-grant §3.1:
- header
typ: oauth-id-jag+jwt; - claims
iss,sub(from the grant, never from the request),aud,client_id,jti,exp,iat,resource; - a short lifetime, about 60 s.
- header
-
Without Pluggable actor-token validation at ID-JAG issuance #6899, ID-JAGs carry no
act. -
upstream_subjectandsub_id. When the target is configured for it, includeupstream_subject(the user's company-IdP identity: issuer plus a configured stable claim, as Emit sub_id (RFC 9493) with the user's upstream identity in access tokens #6900 emits in access tokens) andsub_id(RFC 9493), both read from the grant, which copied them from the subject token when it was created (Refresh tokens through token exchange, as generic grants #6897). A grant that lacksupstream_subjectcannot issue an ID-JAG for a target that requires it: refuse withinvalid_requestand a stable reason of its own, named in the implementation and documented in the profile. The target's authorization server finds the local user fromupstream_subject, in both embedded and external mode, and compares it with the approving user's identity when an approval is created. The target must not use either claim to link accounts on its own, only through its configured subject mapping and approval (§9.5). -
Only grants can produce ID-JAGs. This server issues ID-JAGs only from grants, never from ID tokens or access tokens (§4.3 allows ID tokens; this profile does not), so only a client holding a revocable grant can mint them.
-
Audit: an
exchange_grant.id_jag_issuedlog line with client,sub, target, ID-JAGjti, and whether the grant has a parent. Never token values.
Acceptance:
- an ID-JAG from this server is accepted by a ToolHive gateway's redemption;
- an
audienceorresourceoutside the client's configured targets is refused withinvalid_target; - a revoked grant gets
revoked; - a child grant whose parent is revoked gets
parent_revoked; - a grant that lists
refresh_tokengetsnot_issuable; subcomes from the grant even if the request tries to set it;- an ID-JAG for a target that requires
upstream_subjectcarries the value the grant recorded, also when the grant is a child; a grant without it is refused.
Activity
Name the ID-JAG JWT type once (#7070)
Prevent ID-JAGs from being used as access tokens (#7089)
Name RFC 8693 N_A and issued_token_type once
Add oauthproto/idjag for the XAA client side
Log ID-JAGs that depart from the draft
Add oauthproto/idjag with the XAA client and server rules (#7103)
Leave resource handling to the ID-JAG path
Mint ID-JAGs from exchange grants
Test ID-JAG redemption across two servers
Document minting ID-JAGs from exchange grants
Mint ID-JAGs from exchange grants
Test ID-JAG redemption across two servers
Document minting ID-JAGs from exchange grants
Mint ID-JAGs from exchange grants (stacklok#7130)