Repository navigation
Turn on subject resolution at ID-JAG redemption - #7356
Conversation
Pin the sessionless claims on resolved ID-JAG redemptions so issued tokens stay eligible for delegated admission, and check that the ID-JAG handler's issuance adds no refresh token and that redemption grants no scope. Co-authored-by: Mecatl <[email protected]>
Guard against resolving synthetic sign-ins after an upstream switches to OIDC under the same name. A retained upstream-token row must not establish a local identity. Co-authored-by: Mecatl <[email protected]>
Prove the delegated access path in process across AS-1, AS-2 (subject_mode: resolve with user-keyed upstream storage) and vMCP (upstream_inject with the user credential reader): the redeemed token's call reaches the backend with exactly Alice's GitHub token, and each refusal reaches no backend. Also cover the first-connect order (an ID-JAG refused before the user signs in redeems after it), an expired GitHub row refreshed through the delegated read on memory and Redis storage with the row shared by the interactive route, and a row owned by another user. The test lives in pkg/vmcp/server because the AS-chain helpers and the vMCP credential harness it combines are test code in that package. The tests are skipped while subject resolution is closed; the change that turns it on removes the skip. They pass with it on, under -race. Co-authored-by: Mecatl <[email protected]>
Redemptions from resolve issuers were refused as an unknown subject by a compile-time gate while the pieces behind it landed. Those pieces are in, so remove the gate, its startup warning and the stale comments. The tests that pinned the closed gate become reachability tests: a resolve issuer now issues the resolved user's token, refuses an unknown subject with the ID-JAG unconsumed, and checks the actor after the actor-issuer allowlist. The delegated access end-to-end tests are no longer skipped. Co-authored-by: Mecatl <[email protected]>
A resolve issuer's redemption issues no refresh token and grants no scope, even when the client asks for offline_access, because a redemption has no login session to refresh. The ID-JAG is single use: presenting it again is refused as invalid_grant and leaves the first token stored, while a fresh ID-JAG for the same user redeems to an equivalent token. That is the retry Mecatl makes. AS-1 ignores an unknown exchange parameter on the ID-JAG request, neither refusing it nor copying it into the ID-JAG. Co-authored-by: Mecatl <[email protected]>
AS-2 in the flow test now resolves the ID-JAG's upstream subject to a local user, as a gateway does. The user signs in at AS-2 once through the company IdP, and AS-2 runs with user-keyed storage. The redeemed sub is the user that sign-in created, which the test reads back from the user and provider-identity rows. The token also carries the delegated-access marker and no_upstream_session, has no tsid, and expires no later than the ID-JAG. The memory and Redis subtests change AS-1's storage; AS-2 runs on memory in both. Co-authored-by: Mecatl <[email protected]>
Resolve mode is no longer refused at redemption, so replace the page's description of the closed gate. Say what a resolved token carries (the local sub, the delegated-access marker, no_upstream_session, no tsid, no refresh token, the five-minute cap) and what a gateway needs before an embedder turns resolve on. Co-authored-by: Mecatl <[email protected]>
83e0898 to
5b88b51
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7356 +/- ##
==========================================
- Coverage 82.69% 82.68% -0.02%
==========================================
Files 947 947
Lines 97369 97351 -18
==========================================
- Hits 80519 80492 -27
- Misses 16845 16854 +9
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ChrisJBurns
left a comment
There was a problem hiding this comment.
LGTM. With the gate gone, resolve redemptions still run every check before the ID-JAG is consumed, resolved tokens keep their limits, and gateways still fail closed.
One non-blocking suggestion for a follow-up: the server doesn't check at startup that a resolve issuer comes with user-keyed upstream storage (WithUserKeyedUpstreamStorage), which the new docs list as required. Without it, delegated calls fail closed and nothing is exposed, but the operator only finds out at request time. A startup validation error, or at least a warning, would surface the misconfiguration early.
Summary
Stacked on "Read delegated credentials in upstream_inject" (#7355): the base branch is that PR's branch. Retarget this PR to
mainonce that one merges.An authorization server (AS-2) can resolve an ID-JAG's upstream subject to its own local user (
subject_mode: resolve), and a gateway can read that user's upstream credential. The step between the two has been closed on purpose: every redemption from aresolveissuer was refused assubject_unknownby a compile-time gate (delegatedAccessEnabled = false), because the authorization server cannot see whether the gateway behind it handles a delegated token safely. The pieces that make it safe are in now: the resolver and the marked token ("Resolve ID-JAG subjects and issue marked tokens behind the gate" (#7262)), delegated session binding ("Bind delegated sessions to client and actor" (#7315)), user-keyed upstream storage ("Add user-keyed upstream token storage" (#7308), "Add per-user upstream credential reads" (#7323) and "Wire user-keyed upstream storage into the auth server" (#7332)) and the delegated credential read inupstream_inject(#7355). This PR removes the gate, as "Delegated access: turn on subject resolution at ID-JAG redemption" (#7247) asks, and proves the path they were built for:What changed:
checkSubjectModeGate, the startup WARN and the stale comments are deleted. Aresolveredemption now goes from the actor-issuer check straight into resolution, actor policy and issuance. Namespaced redemptions take the code they took before.pkg/vmcp/server): AS-1, AS-2 in resolve mode with user-keyed storage, and a vMCP withupstream_injectin front of a backend that records theAuthorizationheader. The positive case asserts the exact header (Bearer gh-token-alice) and that the resolved user owns the GitHub row. Refusals each reach no backend and are asserted on their exact error: unknown user, another client or actor on the delegated session, a marked token re-exchanged, a two-elementaud,cnf, a missingresourceclaim, GitHub disconnected (fails closed, tool hidden), a row owned by another user, a namespaced issuer, and a marked token at a validator with no audience. It also covers the first-connect order, and an expired GitHub row refreshed through the delegated read, shared with the interactive route, on memory and Redis storage.pkg/authserver): a resolved redemption that asks foroffline_accessgets norefresh_tokenand no scope; an ID-JAG redeems once, a replay is refused, and a fresh ID-JAG redeems; AS-1 ignores an unknown exchange parameter. The delegated agent flow test now runs AS-2 in resolve mode and checks the user and identity-link rows. Two handler-level tests pin the token shape (marker, notsid) and that a synthetic subject never resolves.docs/arch/17-token-exchange-delegation.mddescribes resolve mode as live, what a resolved token carries, and what a gateway needs before an embedder turns it on.Closes #7247
Type of change
Test plan
task test)task test-e2e)task lint-fix)The new and changed tests were run under
-raceon this stack (the delegated access, redemption, flow and resolution tests, and thetokenexchangepackage). The fulltask testis left to CI. Each commit builds on its own, and the end-to-end tests are skipped in the commit that adds them and run from the commit that removes the gate.Changes
pkg/authserver/server/tokenexchangepkg/vmcp/serverpkg/authserverdocs/arch/17-token-exchange-delegation.mdDoes this introduce a user-facing change?
Yes, for embedders that set
subject_mode: resolveon a trusted issuer.Before: every redemption from a
resolveissuer was refused with400 access_denied/subject_unknown, and the server logged a startup WARN that resolution was not enabled.After: when the ID-JAG's
upstream_subjectresolves to a local user, the server issues a token. It carries the local user assub, the delegated-access marker andno_upstream_session, has notsidand no refresh token, grants no scope (the response'sscopemember is empty andscpis empty), and lives at most five minutes. An ID-JAG can be redeemed once, so a client needs a fresh one for each token. The startup WARN is gone. Namespaced issuers behave as before.Release note: embedders turning on
subject_mode: resolvemust upgrade every gateway replica first. An older replica binds a marked token's session the way it binds the user's interactive session. The gateway also needs user-keyed upstream storage on the authorization server and a credential reader. Mecatl must pin a release containing this change before it configuresresolve.Special notes for reviewers
main.upstream_injectbackends only. The token-exchange, AWS STS, Entra OBO and XAA strategies get their delegated-route behaviour from "Route exchanges through shared subject tokens" and "Route XAA through shared ID token lookup", which are not in this stack, and nothing here tests a marked token at those backends.scopemember, which RFC 6749 section 3.3 requires because it differs from a requested scope; omitting it would claim the requested scope was granted. vMCP's opt-in per-tool scope check reads ascopeclaim by default while this server emitsscp, so a delegated token getsinsufficient_scopeon any tool with a scope requirement. That is unchanged here.resolvestill requires an OIDC first upstream. Nothing at the authorization server checks that user-keyed storage is on or that the gateway has a reader; the docs state it as a requirement on the gateway.pkg/vmcp/serverbecause the vMCP harness and the AS-chain helpers it combines are test code in that package, and test code is not importable frompkg/authserver. It builds on thechain*helpers there. The two-server fixtures inpkg/authserverare a separate copy; converging them into one importable fixture would be its own change.NonFatalSecondaryLegsis not exposed throughRunConfig), and more than one replica. The real-path check is Mecatl's kind test.