Repository navigation
Description
Part of #6909. Token-exchange part depends on #6910 (the subject token must carry
details). Refresh part depends on #6913.
Problem: with #6894, a token exchange can return details that the subject
token never had. The Grant hook can refuse that, but nothing makes it check.
For audience, ToolHive already enforces "never wider than the subject token":
ensureAudienceSubsetOfSubject in
pkg/authserver/server/tokenexchange/handler.go refuses with invalid_target.
Details need the same rule.
RFC 9396 §6 says the AS checks whether the underlying grant allows the
requested details and otherwise refuses with invalid_authorization_details.
It names authorization_code and refresh_token. Treating the subject token as
the underlying grant for token exchange is our reading, not something RFC 9396
or RFC 8693 states. §6.1 says there is no standard way to compare two sets of
details, that the comparison depends on the type definition, and that the AS
should not rely on simple object comparison in most cases.
Change:
- Each type may provide a
Covers(granted, requested)hook. - Token exchange: when the subject token carries
authorization_details, every
requested entry must be covered by an entry of the same type in the subject
token. Otherwise refuse withinvalid_authorization_details(RFC 9396 §6,
§8). A type that has entries in the subject token but noCovershook allows
only entries identical to the subject token's entries (RFC 8259 equality, as
RFC 9396 §12 requires for strings). - If the request leaves out
authorization_details, the issued token carries
the subject token's details for the new audience (filtered as in Convey granted authorization_details to resource servers #6910). RFC 9396
§7 leaves this to the AS. - Refresh: a refresh request with
authorization_detailsmust be covered by the
details stored with the grant. Without the parameter, the stored details
apply. Same rule as forscopein RFC 6749 §6. The stored grant is not
changed (RFC 9396 §6.1). - Run the check before the
Granthook, so a hook never sees a request wider
than the subject token.
Acceptance:
- Exchanging a token with
writeon repo X forreadon repo X succeeds when
the type'sCoverssays write covers read. Asking for repo Y is refused. - A type without
Coversaccepts only identical entries. - A refresh can narrow but never widen, and the next refresh without the
parameter gets the original stored details back.
Open questions:
- Should
locations(§2.2) be checked against the granted audience, the way
§12 suggests it limits where a token is used? That would tie this rule to
ensureAudienceSubsetOfSubject. - External subject tokens (trusted issuers): use their
authorization_details
claim as the upper bound, or ignore it and let theGranthook decide? - Refresh grants run inside fosite. Can this use the handler seam proposed in
authserver: let embedders validate refresh-token grants, and type upstream refresh rejections #6901?
Activity
Process the ID-JAG authorization_details claim (#7290)