Repository navigation
docs(agent-identity): specify delegated access to provider credentials - #2523
Conversation
ChrisJBurns
left a comment
There was a problem hiding this comment.
Overall this looks good to me. The approval flow is simpler and stronger than the old consent link: comparing the company identity the user signs in with against the ID-JAG's, with no callback, state, or PKCE, also covers forwarded, CLI, and cross-device approvals. The actor validator living in the broker matches what we built in #2476 (VerifyCredential).
Four points inline:
- Session ownership moving from
sub_idtoupstream_subjectconflicts with what we agreed after #2497 and with the merged code. This one needs a decision before merge. - Shared signing key: step (4) now allows one key for both slots, but
implementation.md's "One key per role" still says separate keys. - ID-JAG re-submission by default: could the embedded gateway stay single-use for Mecatl, since the broker never re-submits?
- "AS-2 trusts its own comparison, not AS-1's claim" holds at approval time; on each later redemption AS-2 finds the user from AS-1's
upstream_subject.
Two of your open decisions affect sign-in work already filed: broker client authentication on Kubernetes (#2489 assumes private_key_jwt with a key), and how AS-2 knows the user in embedded mode (the gateway-call drafts carry it as pending).
|
|
||
| - ToolHive's subject claim at AS-1 and AS-2. Each server uses it as the key of its local user. | ||
| - The claim that AS-1 puts in its access tokens and ID-JAGs as `upstream_subject`. | ||
| - Mecatl's session ownership. mecak8s's owner key and AS-1's session-open owner check (check 5 in [step (3)](#3-session-open-and-the-broker-refresh-token)) both read `upstream_subject`. They accept it only if its `(iss, claim)` pair is on an allowlist. |
There was a problem hiding this comment.
Ownership on upstream_subject vs sub_id. After #2497 we agreed to keep session ownership on sub_id and document that, with Entra, re-registering AS-1 loses users' access to their sessions. #2497 merged that way: --oidc-owner-identity=sub_id keys owners on the iss/sub inside sub_id, and #2492 (AS-1's session-open owner check) and #2494 / PR #2524 (the harness's owner check) build on sub_id too.
If upstream_subject is the decision, that's fine, and #2497 kept it additive: the flag is a value flag, so this would be a new --oidc-owner-identity=upstream_subject value plus the (iss, claim) allowlist, with #2492's owner check and the harness following. Owner keys stay the same where the claim is sub (Okta, Google, Keycloak) and move from sub to oid on Entra, a one-time remap. One operational note: ToolHive emits upstream_subject only for audiences configured through Go-only SubjectIdentifierAudiences, so hosting AS-1 (#2490) would have to enable it.
Can you confirm which one wins? I'll file the follow-up and adjust #2492 if it's upstream_subject.
There was a problem hiding this comment.
You're right, ownership stays on sub_id as #2497 built it, so #2492 and #2524 need no change. I've rewritten "Identifying claim" as two claims answering two questions: session ownership uses sub_id (only AS-1's registration is involved, so a per-application sub is enough), and the gateway uses upstream_subject, configured per IdP as ToolHive's subject claim at AS-1 and AS-2 (oid on Entra), because AS-1 and AS-2 are different registrations. The section documents the Entra case: replacing AS-1's registration orphans sessions until owners are remapped, no data is exposed, and with the subject claim set to oid AS-1's own subjects survive, so a remap is possible through them. Moving ownership to upstream_subject is listed under later work, using the additive flag value you left room for.
One note on the hosting cost: in ToolHive both claims come from the same SubjectIdentifierAudiences setting, so enabling upstream_subject at AS-1 needs nothing beyond what #2497 already requires.
The administrator pre-approval sentence now says the mapping is created from AS-1's upstream_subject rather than sub_id, to match how AS-2 resolves users. The branch is rebased on main after #2497.
| **Why.** The SVID gives agent identity its own SPIFFE trust domain and bundle, so verifiers can tell it apart from the OAuth issuers, and leaves a path to attestation and to policy shaped by RFC 9396 `authorization_details`. | ||
|
|
||
| The SVID carries a single audience, the broker's, as JWT-SVID §7.2 recommends. AS-1 is configured to accept that value as its own SVID audience, because the broker presents the same SVID to both. That holds only while AS-1 is a broker module; an AS-1 outside the broker needs its own audience and a second SVID. | ||
| **Signing keys.** Configuration has two key slots: the agent-instance issuer's SVID signing key, and the broker's `private_key_jwt` client-assertion key. A simple deployment may point both slots at the same key. The two tokens still cannot replace each other. A client assertion has `iss` and `sub` equal to `mecatl`, so it fails SVID check 1. Mecatl's SVIDs have a SPIFFE `sub` and no `iss`, so they fail `private_key_jwt` client authentication. Production deployments SHOULD use separate keys, because a shared key shares compromise and rotation. Where SPIFFE client authentication is enabled, no client's registered SPIFFE ID may fall in `agents.example.com`. |
There was a problem hiding this comment.
Shared key vs one key per role. This allows the SVID key and the broker's client-assertion key to be the same key, but implementation.md "Modulith constraints" ("One key per role. AS-1, the broker client mecatl, and the agent-instance issuer each use their own key") is unchanged, so the two now disagree. #2489 also requires the broker client key to be separate from the agent issuer's. I'd keep them separate in mecak8s, since it costs nothing and avoids shared compromise and rotation, and make the two sections say the same thing.
There was a problem hiding this comment.
Agreed. The agent-instance issuer and the broker client keep separate keys, so the text matches "One key per role" and #2489 again. The README line and the credential-roles row are back to main's wording. What's left of the paragraph is the SPIFFE caveat: where SPIFFE client authentication is enabled, no client's SPIFFE ID may fall in the agent trust domain, or an SVID could pass as a client assertion.
| | --- | --- | | ||
| | Embedded | Users log in to AS-2 through AS-1, so the AS-1 subject maps directly. AS-1 is the SSO IdP AS-2 trusts (§4.1). Consent is implicit. AS-1 and AS-2 are distinct issuers with distinct keys, so no issuer redeems its own ID-JAG; embedded mode is still outside §9.3's scope. | | ||
| | External | Identity chaining across administrative domains. AS-2's users log in through their own IdP, so the §4.1 SSO precondition does not hold. AS-2 redeems only for an AS-1 `(iss, sub)` and client `mecatl` with a consent link to a native user, created once through AS-2's own login. No just-in-time provisioning. | | ||
| 5. `jti` reuse follows the issuer's policy; by default AS-2 allows re-submission until `exp` (§4.4.3). Every redemption re-checks the approval. |
There was a problem hiding this comment.
Re-submission by default. Mecatl's broker never re-submits an ID-JAG, so single use costs Mecatl nothing and keeps a stolen ID-JAG to at most one redemption. Could the design say the embedded gateway is configured single-use for Mecatl's issuer, and that external gateways are asked to do the same, rather than leaving it to the default?
There was a problem hiding this comment.
Agreed. Step (8) check 5 now says the embedded AS-2 is configured for single use for AS-1's issuer, with used jtis kept in storage shared by all replicas, and that external gateways are recommended to do the same. It costs nothing because the broker never re-submits, and it turns a stolen ID-JAG redeemed first by a holder of the broker key into a visible failure of the broker's own redemption. ToolHive's general default for other issuers is unchanged. The gateway administrator checklist, the tests and audit follow.
| - the consent screen shows which Mecatl account is being linked; | ||
| - where possible, the identity consistency check below. | ||
| - The identity comparison is the defense. If someone else approves a forwarded link, the approval fails, because their IdP identity is not the one in the ID-JAG. The comparison does not depend on the browser, so it also covers CLI, cross-device, and silent approvals. | ||
| - The comparison uses a stable identifier (IdP issuer and a non-pairwise subject, or a configured immutable claim), never email or display name. AS-2 trusts its own comparison, not AS-1's claim (ID-JAG §9.5). |
There was a problem hiding this comment.
Approval time vs redemption time. "AS-2 trusts its own comparison, not AS-1's claim" holds when the approval is created. On every later redemption, though, AS-2 finds the local user from the ID-JAG's upstream_subject, which is AS-1's claim, and the approval row doesn't store AS-1's subject. So a compromised AS-1 can still name any user who has approved Mecatl; the protection is that only approved users are reachable. That's the same trust as the old link keyed on the AS-1 sub, so not a flaw, but worth stating here so readers don't take the comparison as covering redemption too.
There was a problem hiding this comment.
Good catch. The link-swapping bullet now separates the two moments: when the approval is created, AS-2 trusts its own comparison; on each later redemption it finds the user from the ID-JAG's upstream_subject, which is AS-1's claim, so a compromised AS-1 can name any user who has approved Mecatl, but no one else.
Define how a delegated client such as Mecatl's broker uses a user's existing gateway connections: what AS-1 issues, how AS-2 decides which local user and whether the client may act for them, and what the gateway reads. The ToolHive side is tracked in stacklok/toolhive#6886 (issuing), AS-1 (credentials-and-lifecycle.md, steps 4 and 7) - AS-1 confirms the acting agent through ToolHive's pluggable actor-token validator (stacklok/toolhive#6899). Mecatl's implementation runs in the broker against its instance registry and returns the agent's ag_ identifier; AS-1 puts it in act.sub and caps the ID-JAG's exp at the SVID's. Why: AS-1 is ToolHive's server and cannot read Mecatl's registry, and the SVID carries only the claims JWT-SVID requires. - "Does not prove" now says the agent check is the broker checking its own registry. A built-in JWT-SVID validator with a session claim stays later work, for an AS-1 that runs apart from the broker. - The agent-instance issuer and the broker client each keep their own key, as "one key per role" already requires. Where SPIFFE client authentication is enabled, no client's SPIFFE ID may fall in the agent trust domain, or an SVID could pass as a client assertion. AS-2 (credentials-and-lifecycle.md step 8, mcp-gateway-modes.md) - Redemption maps the source user to a local user and checks approval: implicit in embedded mode; in external mode the local user is the one whose shared-login identity is the ID-JAG's upstream_subject, trusted only because the approval compared it with AS-2's own login (ID-JAG section 9.5). - An approval is one row per (gateway, local user, client, actor_iss), required actor_iss, no stored copy of AS-1's subject. Why: storing the source subject per approval allowed two rows to map one source user to different local users. - The actor rule: only the top-level act counts; an act without iss uses the token's iss; no act means no actor. - The embedded AS-2 accepts each ID-JAG from AS-1 once, and external gateways are recommended to do the same. It costs nothing because the broker never re-submits, and a stolen ID-JAG redeemed first by a holder of the broker key shows up as a failure of the broker's own redemption. ToolHive's general default (re-submission until exp for new issuers) is unchanged. Single-use leftovers in README, gateway modes, audit and the failure matrix are corrected. - V from an approved redemption carries the delegated-access marker (stacklok/toolhive#6404), is terminal as subject and actor token, and is the only thing that reaches the user-keyed read; a missing tsid or an act claim never stands in for it. - The vMCP binds a session to iss, sub, client_id, act.iss, act.sub and the marker, consistently in step 9 and "Sessions at the vMCP". Approval link (implementation.md "External consent link") - AS-2 refuses an unapproved ID-JAG with consent_required and an error_uri to a pending approval, under a profile AS-2 advertises in its metadata. Mecatl shows AS-2's own link; it adds no callback, state or PKCE, and resumes by redeeming a new ID-JAG. - On approval AS-2 compares the company IdP identity the user signed in with against the ID-JAG's, activates on a match and discards the pending approval on a mismatch. Why: this stops link swapping without a browser, so it also covers CLI and cross-device use, while a Mecatl callback needed a web session Mecatl does not have and did not stop a forwarded link anyway. - AS-2 offers user approval only for issuers that share its company IdP; otherwise plain invalid_grant and no link, leaving administrator pre-approval. The broker shows an error_uri only from a gateway that advertises the profile, on AS-2's https origin. Ledger and tests (implementation.md) - The ToolHive work list links the posted issues instead of "no issue covers it": #6887, #6404, #6407, #6885, #6888, #6892 and the #6886 sub-issues (#6893-#6900); #6894 and #6900 are marked done. - Tests cover the approval comparison, the marker, re-submission policy, the actor rule and the validator. - Removed: issue triage pinned to a commit, a costs paragraph that repeated the table, and duplicated explanations. Identifying claim (credentials-and-lifecycle.md "Identifying claim") - Two claims identify a user and answer different questions. Session ownership stays on sub_id, as merged in #2497: only AS-1's application registration is involved, so a per-application sub is enough. The gateway uses upstream_subject, configured per company IdP as ToolHive's subject claim at AS-1 and AS-2 (oid for Entra, sub where it is the same across applications), because AS-1 and AS-2 are different registrations. - On Entra, replacing AS-1's registration orphans sessions until owners are remapped; the section says so, and moving ownership to upstream_subject is listed as later work. threat-model.md and audit.md follow the same terms. Terminology: new text calls the stored record an "approval" (it can come from the user or an administrator). Existing lines that say "consent link" are left unchanged to keep this diff reviewable; a mechanical rename can follow separately. Co-Authored-By: mecatl <[email protected]>
2692341 to
a56b908
Compare
|
Thanks, the update resolves all four comments: session ownership stays on I've noted the two new points on the sign-in tickets: AS-1's subject claim setting on #2490, and the open |
Summary
Specifies how a delegated client such as Mecatl's broker uses a user's existing gateway connections: what AS-1 issues, how AS-2 decides which local user a request is for and whether the client may act for them, and what the gateway reads. The ToolHive side is tracked in stacklok/toolhive#6886 (issuing), stacklok/toolhive#6887 (subject mapping and approval) and stacklok/toolhive#6406 (gateway read).
ag_identifier foract.sub. AS-1 cannot read Mecatl's registry itself, and the SVID carries only the claims JWT-SVID requires. A built-in SVID validator with a session claim stays later work.oid, orsubwhere it is stable across applications). ToolHive's subject claim at AS-1 and AS-2, theupstream_subjectclaim, and Mecatl's session ownership all use it, from an(iss, claim)allowlist. With Entra's per-applicationsub, AS-1 and AS-2 would never agree on a user, and re-registering AS-1 would cost every user their sessions and approvals.upstream_subject. An approval is one row per (gateway, local user, client,actor_iss). ID-JAG re-submission is allowed untilexpby default for new issuers; existing configurations keep single use.Vfrom an approved redemption carries a marker (Add a delegated-access marker that gates credential lookup for approved delegated tokens toolhive#6404). It cannot be exchanged further, and it is the only thing that reaches the user-keyed credential read.consent_requiredand anerror_uri. Mecatl shows AS-2's own link and adds no callback,stateor PKCE. When the user approves, AS-2 compares the company IdP identity the user signed in with against the ID-JAG's and activates only on a match. Per-user approval requires a shared IdP; otherwise only administrator pre-approval applies. Mecatl has no browser session to bind a callback to, and the identity comparison stops forwarded links without one.Issue relationship
Relates to #2451
Relates to stacklok/toolhive#6886, stacklok/toolhive#6887, stacklok/toolhive#6406, stacklok/toolhive#6899
Type of change
Test plan
Baseline checks
task lint)task test)task test:race)go run ./cmd/mecademo)task docs). Not run in full; the strict link check it runs (matlatl check . --strict) passes on a clean checkout with 0 broken links or anchors. No code changed.task site:build)task api:check)task api:update+engine/CHANGELOG.mdChanges
docs/drafts/agent-identity/credentials-and-lifecycle.mddocs/drafts/agent-identity/implementation.mddocs/drafts/agent-identity/mcp-gateway-modes.mdREADME.md,audit.md,run-owner.md,threat-model.mdUser-facing change
None. Design drafts only.
Special notes for reviewers
mainkeys external-mode approval on AS-1'ssub; this PR finds the local user fromupstream_subjectand compares it at approval time. Please review the approval-link section inimplementation.mdtogether with step (8).sub_idtoupstream_subject. mecak8s's owner key and AS-1's session-open owner check move together.private_key_jwtwith a key, SPIFFE client authentication, or a KMS key).