Repository navigation
Description
Follow-ups from the review of #7003 (issuing refresh tokens through token exchange) that need a decision or more than a mechanical change, so they were kept out of that PR to let it merge.
Require offline_access on the subject token
The Mecatl design (credentials-and-lifecycle.md, step (3) check 4) says the subject token "was issued with the offline_access scope, which ToolHive's exchange handler requires". The handler does not check scopes today: checkLoginToken and checkExchangeGrantSubject never read ValidatedClaims.Scopes. #6897 does not list the check, which is how it was missed.
- Add the check to
checkLoginToken, since every refresh-token profile needs the user's offline consent (OIDC Core section 11). - It needs its own reason.
subject_token_invalidis wrong because it tells the client a fresh access token fixes it, and only a new sign-in that requestsoffline_accessdoes. Something likesubject_token_scope. The Mecatl broker maps unknown reasons toINTERNAL, which fits, but agree the name with the broker side and add it to the design's reason list. - Add a row to the error table in
docs/arch/17-token-exchange-delegation.md.
Log client-caused refusals at debug
Every refusal on the exchange refresh-token path logs at warn ("Exchange grant refused"). With AllowPrivateKeyJWTRegistration on, anyone can register a client through DCR that has the token-exchange grant. That client has no exchange policy, passes client authentication and is refused with a warn, and token requests are not rate-limited per client, so the warn log can be flooded. The token endpoint logs 4xx at debug for this reason.
- Log refusals the client causes at debug; keep warn for store and internal failures.
- Update the PR Issue refresh tokens through token exchange #7003 "Accepted trade-offs" wording and the logging section of docs/arch/17.
End-to-end test with a real login access token
The handler and integration tests mint subject tokens by hand. checkLoginToken depends on the exact claim shape of a login access token (client_id, jti, sub, no act, the upstream-session marker), so a change in how login tokens are minted would not be caught. Add one test that signs in through the mock OIDC flow (completeAuthorizationFlow), exchanges the resulting access token for a refresh token, and checks that a grant exists. The real-login helpers and the exchange-client setup use different fixtures today, so they need joining.
HTTP test for the public-client refusal
The public-client refusal in RefreshTokenHandler is only covered by a unit test. First check whether fosite rejects a public client before the handler runs. If the handler's own check is reachable over HTTP, add a case for it to the integration suite; if not, say so in a comment next to the check.
Activity