Skip to content

Follow-ups from the exchange refresh token review #7011

Open

Description

@jhrozek

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_invalid is wrong because it tells the client a fresh access token fixes it, and only a new sign-in that requests offline_access does. Something like subject_token_scope. The Mecatl broker maps unknown reasons to INTERNAL, 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.

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

  1. added
    needs-triage
    on Oct 30, 2026
  2. removed
    needs-triage
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions