Skip to content

Configure the embedded gateway's authorization server as AS-2 #2533

Done

Description

@ChrisJBurns

Depends on: a pinned ToolHive release that resolves ID-JAG subjects ("Delegated access: turn on subject resolution at ID-JAG redemption" (stacklok/toolhive#7247), in v0.70.1).

Part of this ticket is done (#3002): AS-2 trusts AS-1 for ID-JAGs only, issues at+jwt gateway tokens, fetches AS-1's keys from a private address only when asked, and tests cover its step (8) refusals and the vMCP's refusal of bad gateway tokens. This ticket is the rest.

Problem

The embedded gateway's authorization server is meant to act as AS-2. In production it trusts no ID-JAG issuer, so every authorized gateway call fails closed, and mecak8s refuses servers in the identity broker's embedded gateway entry. Only tests trust an AS-1, one they start themselves, and only for subjects they list. The gateway token names the AS-1 subject rather than a gateway user, so the gateway cannot find that user's provider credentials.

Design

Implements:

Requirements

With the identity broker on:

  • Trust in AS-1. AS-2 trusts AS-1 in production, as an ID-JAG issuer only, for any subject AS-1 names. User resolution decides who is redeemed, not a list of subjects.
  • AS-1's signing keys. AS-2 fetches AS-1's keys from AS-1's issuer, over HTTPS. Two operator settings, both off by default, cover an AS-1 issuer at a private address with a private CA, as in a cluster: allowing private addresses for that fetch, and a CA bundle to trust. Both are exposed in the Helm chart and described in the operator guide. A private key-set address without the setting fails at startup.
  • Company IdP sign-in at AS-2. AS-2's sign-in starts with the same company IdP as AS-1. It uses its own application registration there: the operator supplies its client ID and secret. The IdP issuer, its CA and the identifying claim come from AS-1's settings, so the two can't differ. AS-2 forces no prompt, so the step is silent while the company session is live.
  • User resolution. AS-2 finds the gateway user from the ID-JAG's upstream_subject, using the same identifying claim as AS-1, and never through sub_id, email or display name. Approval is implicit, set by configuration. An unknown or ambiguous user is refused with subject_unknown, and AS-2 creates no user while looking one up.
  • Who may redeem. Only client mecatl may redeem, with the agent trust domain as the actor's issuer, for the vMCP resource. Anything else is refused with actor_denied or resource_denied.
  • Gateway token. It names the gateway user, keeps the ID-JAG's act and the client mecatl, is for the vMCP only, carries the delegated-access marker, lives no longer than the ID-JAG, and comes with no refresh token. A marked token is refused at token exchange, whether presented as the subject or the actor token.
  • Production gateway entry. Startup accepts servers in the broker configuration's embedded gateway entry, in mecak8s and in the Helm chart.
  • Operator guide. It covers AS-2's registration at the company IdP and the caveats real IdPs bring: a first-time consent screen (in Entra, grant admin consent), an account picker when several accounts are signed in, and conditional access or MFA step-up.

With the flag off, nothing changes.

Not here: using the user's provider credential and the connect link (#2537), tool listing (#2729), and the kind fixture (#2542).

Shortcuts

Removes:

Keeps:

Done when

Tests run against the real embedded ToolHive authorization server as AS-2 and the real hosted AS-1, built through mecak8s's startup wiring, with servers in the production gateway entry and no test-only trust. They show that:

  • a valid AS-1 grant redeems for a marked gateway token naming the resolved gateway user, and the vMCP accepts it;
  • an unknown user is refused with subject_unknown and no user is created, and a matching sub_id without a resolved user is refused;
  • an unaccepted actor issuer is refused with actor_denied, and a disallowed issuer, client or resource is refused with resource_denied;
  • a marked gateway token is refused at token exchange as the subject and as the actor token;
  • AS-2 configured with a private key-set address, and without the setting, fails at startup.

#3002's tests still pass. With the flag off, nothing changes.

Activity

  1. 16 remaining items

  2. ChrisJBurns commented on Nov 26, 2026

    @ChrisJBurns
    ContributorAuthor

    #3002 does the part of this ticket that ToolHive v0.69.0 allows. AS-2 now trusts AS-1 for ID-JAGs only and issues at+jwt gateway tokens, and the step (8) refusals have tests.

    Production trust needs this decided:

    • Key fetch from a private address is now explicit. The trust's key-fetch setting is off by default, and ToolHive refuses a key set URL that names a private or loopback address unless it is on. mecak8s hosts AS-1 in the same process, so AS-2 reaches AS-1's keys over loopback or an in-cluster address. The production trust must set the operator's "AS-1 key fetch from a private address" setting deliberately (the AS-1's signing keys bullet above). Otherwise AS-2 fails at startup rather than at redemption. The setting, its Helm value and the operator guide entry belong with that change.
  3. ChrisJBurns commented on Nov 28, 2026

    @ChrisJBurns
    ContributorAuthor

    Done in #3002, #3014, #3015 and #3018.

    With the --identity-broker-as2-* settings (Helm: identityBroker.as2), the embedded gateway's authorization server (AS-2) trusts the hosted AS-1:

    • It accepts ID-JAGs only, and resolves each user through the company IdP, which comes first in AS-2's sign-in.
    • It accepts only the agent trust domain as the actor's issuer.
    • Its gateway tokens are marked and capped at 5 minutes, and can't be exchanged.

    Startup builds the trust from AS-1's own settings, and the gateway entry may list servers. Without the settings, nothing changes.

    Where the result differs from "Done when":

    • resource_denied can't occur with AS-2's configuration: the broker client may request only the vMCP resource, and no other client can redeem. Those requests are refused with invalid_assertion or invalid_target instead.
    • Through mecak8s's flags, the tests cover a redemption for the resolved user, the subject_unknown refusal, the marked token, vMCP acceptance, and the private-address key fetch. The actor_denied refusal, the exchange refusals and "no user created" are tested on the same trust type at the adapter level, not through flags.
    • The trust can still be set on an external AS-1, for tests that need fault injection and a movable clock. No flag sets it.

    Shortcuts this leaves, each listed in #2451 with what removes it:

    The company IdP step keeps offline_access permanently, so the IdP must issue AS-2 a refresh token without a consent prompt. This keeps a later on-behalf-of (OBO) exchange with the company IdP possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions