Skip to content

Delegated access: tokens and actors from third-party issuers #7159

Open

Description

@jhrozek

Problem: "Delegated access: subject mapping at ID-JAG redemption" (#6887) resolves users and actors for ID-JAGs redeemed at the gateway's authorization server (AS-2). Its packages ("Delegated access: subject resolver and actor policy packages", #7157) already model third-party issuers: the actor source client for Entra, the issuer-less act for Okta, and a standalone resolver that can map more than one issuer to the same identity provider (for Okta custom authorization servers). Nothing calls them for those issuers yet.

An agent platform other than Mecatl reaches AS-2 in ways "Delegated access: subject mapping at ID-JAG redemption" (#6887) does not handle:

  • with an ID-JAG that the identity provider issued itself (Okta, Entra), which carries no https://toolhive.dev/upstream_subject. "Delegated access: subject mapping at ID-JAG redemption" (Delegated access: subject mapping at ID-JAG redemption #6887) resolves only that ToolHive-private claim;
  • with its own token, through RFC 8693 token exchange;
  • with an actor token that AS-2 did not issue;
  • with ID-JAGs from an issuer that expects reuse until expiry.

Today these fail closed:

  • An ID-JAG from an identity provider resolves to iss#sub with no marker, and configuration refuses subject_source: issuer_claim until item 0 is built.
  • An external subject on AS-2's token exchange becomes iss#sub with no marker (delegatedSubject in handler.go), so it cannot reach any credentials.
  • An actor_token must be one AS-2 issued itself (selfValidator in handler.go).
  • Every ID-JAG is single use.

Build each item when a caller needs it. The direct route ("Accept directly presented tokens from configured issuers at the vMCP", to be filed) is the other way a third-party token reaches a user's credentials, resolving per request at the vMCP with the same packages. Decide per caller which route it uses.

Where these run

 client holds an ID-JAG minted by the identity provider X itself
   ── RFC 7523 jwt-bearer at AS-2 ──> AS-2
      today:  sub = "X#sub", no marker
      item 0: Ref{X, binding_claim, <binding_claim value in the ID-JAG>} -> U

 client holds T from issuer X (Okta, Entra, another authorization server)
   ── RFC 8693 at AS-2: subject_token=T [, actor_token=A] ──> AS-2
      today:  sub = "X#sub(T)", act nests X's actor, external_issuer = X, no marker
      item 1: resolve X's binding claim -> U  (marker only after item 1's approval decision)
      item 2: A may come from a configured external issuer or SPIFFE trust domain
   ── MCP call ──> vMCP ── (only with the marker) ──> U's credential

 client holds an ID-JAG from a third-party issuer that expects reuse
   ── RFC 7523 jwt-bearer at AS-2 (twice, same jti) ──> AS-2
      item 3: accepted until exp when that issuer is configured for reuse

0. Resolution from an identity provider's own ID-JAG

"Delegated access: subject mapping at ID-JAG redemption" (#6887) reserves the setting value subject_source: issuer_claim and refuses it in configuration. This item builds it.

  • For a trusted issuer with subject_mode: resolve and subject_source: issuer_claim, the lookup key is Ref{<ID-JAG iss>, binding_claim, <value of binding_claim in the ID-JAG>}. upstream_subject is not read. Third-party identity providers are never asked to add a claim.

  • Per-provider profiles from the design (delegated-access proposal, "Profiles"), to be confirmed against real tokens before they become defaults:

    generic Okta Entra Keycloak
    binding claim sub (operator confirms it is immutable) uid oid, with tid equal to the issuer's tenant sub
    actor source act act (no iss) client act (unverified)
    issuer form — custom authorization server only; org server refused per-tenant only —
  • The ID-JAG's issuer must be AS-2's identity-provider upstream (the first sign-in leg), or be mapped to it by a cross-issuer mapping in configuration, built here. For Okta, a custom authorization server's uid equals the sign-in ID token's sub, so (custom AS, uid) resolves as (sign-in issuer, sub). The mapping is stated explicitly in configuration, never inferred. The resolver from "Delegated access: subject resolver and actor policy packages" (Delegated access: subject resolver and actor policy packages #7157) already takes a map from issuer to provider and subject claim; this issue adds the configuration that builds it. The startup check from "Delegated access: subject mapping at ID-JAG redemption" (Delegated access: subject mapping at ID-JAG redemption #6887) extends to this case.

  • Entra oid is resolved together with tid: a token whose tid is not the issuer's tenant is refused.

  • A missing binding claim is refused with invalid_grant, invalid_assertion, as in "Delegated access: subject mapping at ID-JAG redemption" (Delegated access: subject mapping at ID-JAG redemption #6887).

  • Confirm before building: whether real Okta and Entra ID-JAGs carry the binding claim (uid, oid and tid), and in which form. Okta's ID-JAG behaviour is unverified in ToolHive's tests. Test against real issuer tokens, and against the xaa.dev sandbox for the generic profile.

  • Tests: a table per profile (found, unknown, missing claim, wrong tenant, issuer not mapped); the cross-issuer mapping for Okta; a two-server-style integration test with a fake identity provider that mints ID-JAGs with the chosen claims (the ledger's integration harness part 2).

1. Resolution on AS-2's token-exchange path

  • subject_mode: resolve (from "Delegated access: subject mapping at ID-JAG redemption" (Delegated access: subject mapping at ID-JAG redemption #6887)) also applies when a trusted issuer's token is the subject_token of an RFC 8693 exchange. The subject resolves through that issuer's binding claim on the token, not through upstream_subject.
  • The same checks as at redemption, where they apply: the actor issuer, the actor policy (with the issuer's actor source, act or client), and the per-(issuer, client, resource) allow.
    • Decide what Request.ClientID means under the client source on this path and on the vMCP direct route, then decide whether the default policy should refuse an Actor whose Subject is not ClientID, or whose Issuer is not the token issuer, and whether it should reject an unknown Actor.Source. At redemption the client is the authenticated client, so such a check cannot fail in correct wiring. Here an Entra token names its own app, while the client asking AS-2 to exchange it may be a different one, and on the direct route there is no AS-2 client, so a check added before this is decided could turn every request into a server error. A failed check would be a Policy error, not a denial, because it points to a caller bug. These were suggested in review of "Delegated access: subject resolver and actor policy packages" (Delegated access: subject resolver and actor policy packages #7157) and left until a caller exists.
  • Decide first: what approval means on this path. A plain Okta or Entra token usually has no act, while the approval record in "Delegated access: user approval at an external gateway" (Delegated access: user approval at an external gateway #7158) is keyed by (gateway, user, client, actor issuer). Until this is decided, a resolved token-exchange subject gets sub = U but no marker, so it still cannot read credentials.
  • Refusals and reason codes as at redemption ("Authorization server: reason codes in error_description for ID-JAG redemption refusals", Authorization server: reason codes in error_description for ID-JAG redemption refusals #7030).
  • Tests: a table for each refusal; the issued sub and act for namespaced and resolve; no marker until approval is decided; a kind e2e that the token reads nothing until it carries the marker.

2. Foreign actor tokens

  • Accept an actor_token issued by a configured external issuer, validated against that issuer's keys and the actor-issuer allowlist, not only tokens this server issued.
  • Accept JWT-SVIDs from a configured SPIFFE trust domain, validated against its bundle.
  • Build one external-actor validator shared with the agent actor profile in "Authorization server: revocation and audit for delegated agents" (Authorization server: revocation and audit for delegated agents #6886); both replace the self-issued-only check (selfValidator) in handler.go.
  • A token carrying the delegated-access marker stays refused as an actor token ("Add a delegated-access marker that gates credential lookup for approved delegated tokens", Add a delegated-access marker that gates credential lookup for approved delegated tokens #6404).
  • Configuration: the actor issuers per trusted issuer and client; the trust domain and bundle source.
  • Refusals: unknown issuer, bad signature, expired, actor issuer not allowed, wrong audience. Each with its exact error.
  • Tests: a table for each refusal; the issued act for an external actor; a JWT-SVID from an allowed and a foreign trust domain.

3. ID-JAG reuse policy per issuer

  • A per-issuer setting: single_use (the default, and what every issuer gets today) or reuse_until_expiry.
  • Single-use issuers keep checking and recording the used jti in one atomic step across replicas (the assertion store, Redis in production).
  • A reuse-allowed issuer still refuses an ID-JAG after its exp, and still refuses a marked redemption if single use is required for the marker (decide with item 1's approval question).
  • Mecatl's issuer stays single use.
  • Tests: reuse refused for a single-use issuer, on memory and Redis; reuse accepted until exp for a reuse-allowed issuer and refused after.

Open question: should a marked token require a resource claim?

Decide before any third-party issuer gets grants_credential_access. Today the only issuer that would get it is a ToolHive AS-1, which always signs the claim, so "Delegated access: subject mapping at ID-JAG redemption" (#6887) does not require it.

Draft -06 §4.4.1 lets the authorization server choose default resources when the ID-JAG has no resource claim, and also lets it refuse when "the claim is required and absent". For an ID-JAG without the claim:

 identity provider X (trusted at AS-2, grants_credential_access: true)
   mints ID-JAG {iss: X, aud: AS-2, sub: alice, act: agent}     ← no resource claim
                                                                   "this agent may act for Alice at AS-2"
 client ── redeem at AS-2, resource = R ──> AS-2
AS-2 serves one vMCP AS-2 serves several vMCPs
Claim not required A marked token for R, the only choice The client picks which vMCP gets a marked token for Alice, within the per-(issuer, client, resource) allow the AS-2 administrator configured. X's administrator has no say in which
Claim required Refused until X sends a claim Refused until X sends a claim; then X's administrator decides too
  • Not required: only the AS-2 administrator bounds which gateway the agent reaches with Alice's credentials. The bound still holds, because the allow is per (issuer, client, resource), but the identity provider cannot narrow it further.
  • Required: both administrators bound it. The cost is that an identity provider that omits the claim cannot be used for credential access at all.

Whether Okta and Entra ID-JAGs carry a resource claim, and with which value, is unverified (Okta's documented redemption sends no resource parameter). Check against real tokens first.

Depends on

Activity

  1. added
    enhancement
    go
    on Nov 16, 2026
  2. added
    needs-triage
    on Nov 16, 2026
  3. removed
    needs-triage
    on Nov 24, 2026
  4. jhrozek commented on Nov 27, 2026

    @jhrozek
    ContributorAuthor

    While reviewing "Bind provider-identity rows to their issuer and claim" (PR #7347, closes "Bind provider-identity rows to the issuer and subject claim that created them"), we found that item 0's cross-issuer mapping needs more than the configuration that builds the resolver's issuer map. This is what changed.

    The resolver compares against the token's issuer, not the stamped binding. With that PR, every provider-identity row carries the issuer and subject claim it was stamped with at sign-in. The subject resolver compares a row with the issuer the token arrived under and the provider's subject claim. That is fine while there is one issuer per provider. For the Okta case the token issuer is the custom authorization server and the claim is uid, but the row says (sign-in issuer, sub). The row never matches, and every user who already signed in gets subject_unknown. So item 0 also has to make Provider carry the sign-in binding and compare the row with that. The mapping config would supply those values. The PR deliberately does not add these fields, because nothing could set them yet.

    A startup check goes away here. The PR adds a check that refuses a second issuer for one provider, so a config that tries it fails at startup instead of silently refusing users. Nothing can configure a second issuer today, so the check cannot fire yet. Item 0 should remove or relax it once the explicit mapping exists, and it would help to name it in the item so it is not left in place by accident. The existing line about the startup check from "Delegated access: subject mapping at ID-JAG redemption" may or may not be the same check.

    Unstamped rows. Rows from before that PR have no stamp, and the resolver accepts them read-only without stamping them. If a repoint happens before the user signs in again, someone at the new IdP with the same subject value can claim the row. Mapping more issuers to a provider makes more tokens able to hit that window. The item should say whether mapped resolution keeps accepting unstamped rows. A per-upstream binding record that closes the window for every repoint is tracked in "Record the identity binding once per upstream".

    Plain OAuth 2.0 upstreams. For these the stamped issuer is a hashed form (oauth2::sha256:...) of the endpoint's host, not a URL. A mapping to one of them would have to produce that form, or the item should say only OIDC upstreams are supported.

    Please also add that PR to "Depends on", since the row binding this relies on lives there.

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

    authenticationenhancementgosecurity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions