Repository navigation
Description
Delegated access to a user's stored upstream credentials ("Delegated client access to a user's connections", #6406) needs a way for the gateway to tell "this token came through an approved delegated redemption" apart from every other token. Neither the subject's shape nor the absence of a session ID can say that.
Some upstream OAuth providers have no userinfo endpoint, so ToolHive can't resolve a durable identity for that connection and generates a synthetic subject instead. That synthetic subject is UUID-shaped, the same as a real one, so trust can never be inferred from the subject string. Any future proposal along those lines should be checked against this before being reconsidered.
This issue defines the marker and makes it terminal. It is issued by "Delegated access: subject mapping at ID-JAG redemption" (#6887), whose issuance rules are listed there. It lands before #6887, so that no marked token can ever be exchanged into another one.
The marker
- Name:
https://toolhive.dev/claims/delegated_access, defined as a constant inpkg/authserver/claimnames.pkg/auth/token.goalready imports that package, so the vMCP side checks the same constant without an import cycle. Shared contract with the storage track: this issue defines the constant; the credential read in "Ownership-checked credential read for delegated tokens, keyed by user and routed provider" (Ownership-checked credential read for delegated tokens, keyed by user and routed provider #6407) checks it. - Presence only: consumers check that the claim is present, never its value. The value may name the trusted issuer for diagnostics, but no check reads it.
- Honoured only for the embedded issuer: marker presence on a token from any other issuer means nothing. The credential read runs only for a validated token issued by this gateway's own authorization server that carries the marker.
- Internal: added to
internalClaims(pkg/auth/context.go), so middleware sees it in validated raw claims, but it is kept out ofIdentity.Claimsand webhooks.
Refusals: a marked token is terminal
A marked token is refused wherever it could be exchanged into another token, so the marker cannot be laundered into a token that lives longer or names another party. No code issues the marker yet. The refusals land first anyway: this carries security constraint 9 now that ID-JAG issuance has landed ("ID-JAG issuance through token exchange", #6898).
- RFC 8693 token exchange (
pkg/authserver/server/tokenexchange/handler.go): refused as subject token and as actor token. - ID-JAG issuance (
refresh_token_id_jag.go): refused as actor token, before the actor-token validator is called. - Opening an exchange grant (
refresh_token_handler.go,checkLoginToken): already refused today, because a redeemed token carriesactandno_upstream_session. Add an explicit marker case first in the switch, so the refusal does not depend on those two claims staying. - The refusal is checked after signature validation and before any other use of the token's claims.
- The error and reason follow each handler's existing convention. At grant opening, add a stable reason next to the existing
subject_token_*reasons, for examplesubject_token_delegated_access. Reason strings are an API; settle the name in review.
Tests
- Unit tables in
tokenexchangefor each refusal above, with the exacterrorand reason. The marked token is hand-signed with the server's own key (tests inauthserver_testpin it), since nothing can mint one over HTTP yet. - A marked token from another issuer is refused or ignored the same way: the check is on presence in a token this server validated.
- The in-process delegated-agent flow test, step 3 (grant issuance): one more subject-token defect row with a marked token.
-
docs/arch/17-token-exchange-delegation.md: the marker and its refusals.
Why not sub_ns
The earlier proposal here was a sub_ns claim minted at login and passed through token exchange. It answered "is this subject a real, resolved user?". Delegated access needs a different fact: "may this client use this user's connections?". A real user does not imply that every client acting for them is approved. So the marker is issued at redemption, after approval, and login never issues it.
(Removed from the old body: "Depends on "Delegated access: subject mapping at ID-JAG redemption" (#6887): embedded-mode subject mapping and implicit approval land before this". The refusals have no dependency, and issuance moved into "Delegated access: subject mapping at ID-JAG redemption" (#6887).)
Activity
[-]Add sub_ns claim to mark a token as backed by a real resolved user[/-][+]Add a delegated-access marker that gates credential lookup for approved delegated tokens[/+]docs(agent-identity): specify delegated access to provider credentials
docs(agent-identity): specify delegated access to provider credentials
docs(agent-identity): specify delegated access to provider credentials
docs(agent-identity): specify delegated access to provider credentials
docs(agent-identity): specify delegated access to provider credentials
Refuse delegated-access tokens in exchanges
Refuse delegated-access tokens in exchanges