Skip to content

feat(identitybroker): verify an agent credential for a grant's owner - #2733

Merged
ChrisJBurns merged 3 commits into
mainfrom
feat/identitybroker-owner-keyed-verify
Nov 6, 2026
Merged

ChrisJBurns merged 3 commits into
mainfrom
feat/identitybroker-owner-keyed-verify

Conversation

@ChrisJBurns

@ChrisJBurns ChrisJBurns commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2534.

Problem

Before AS-1 issues an ID-JAG naming a user and an agent, it must confirm three things: the agent credential is genuine, the agent's session belongs to the grant's user, and which ag_ identifier names the agent. AS-1 cannot check this itself because it doesn't know Mecatl's agent registry. For client mecatl, it calls an actor-token validator that runs in the identity broker (credentials-and-lifecycle.md, step (7), "How AS-1 runs check 6").

The broker had no check AS-1 could call:

  • Wrong key. The only form, VerifyCredential, is keyed by broker session ID. AS-1 has no session ID; from the grant it has only the user (sub_id).
  • Wrong answers for AS-1. For a closed session, VerifyCredential returns the session's closing reason, which only the broker should report. And it refuses an agent from another session of the same user, which is the broker's step (6) check, not AS-1's.
  • Misleading comments. CredentialVerifier's doc and the conformance suite called the session-keyed check AS-1's.

What

This PR adds the check AS-1 needs: an owner-keyed form of agent-credential verification, VerifyCredentialForOwner, on identitybroker.CredentialVerifier. It takes the grant's owner instead of a session, so AS-1 can call it with what it has. CredentialVerifier stays apart from Core, so no transport serves it. The session-keyed VerifyCredential stays as it is, for the broker's step (6).

The owner-keyed form runs SVID checks 1–7, then check 8 at AS-1, which requires all of:

  • the instance's present broker session is open;
  • that session is owned by the given identitybroker.Owner;
  • the credential was issued since the instance moved to that session.

It refuses only with svid_expired for an expired credential and denied for anything else, including a malformed request, another user's session, and a closed session; no closing reason reaches AS-1. Any other error means the validator could not answer, which AS-1 treats as retryable. On allow it returns the ag_ identifier, the SPIFFE ID, and the credential's exp. Every refusal after the SVID checks carries the same detail text, so even an error passed on whole doesn't tell AS-1 whether the session closed, belongs to someone else, or holds a newer credential.

Comments that called the session-keyed check AS-1's are corrected in boundary.go, agents.go, and the conformance suite.

Decisions

These were agreed before implementation. Each is recorded here and in the code's doc comments.

Design notes

#2726 already put "the instance's session is open" into check 8 at AS-1 on main. This PR brings the remaining passages that describe check 8 into line with it:

  • the failure-matrix row in credentials-and-lifecycle.md adds "closed";
  • implementation.md's AS-1 test bullet adds a closed session, answered denied;
  • the note on an AS-1 outside the broker now says it needs a way to run all of check 8, not just the owner comparison;
  • the "owner claim" later-work item says closing the session, like deregistration, would take effect only at the SVID's exp.

What the open check does at runtime: until AS-1 revokes refresh tokens when a session closes (not wired yet), it is what refuses an exchange whose session closed after the broker's step (6). The refusal is denied, so mapping it back to the closing reason the broker recorded is #2535's job ("Session closed during an exchange"). The check looks at the instance's present session, so a stale exchange for a closed session passes if the instance has already moved to an open replacement with the same owner. Only AS-1's own revocation catches that, as the design's "Does not prove" for check 8 already allows for same-user pairings.

Tests

  • Conformance (conformance/ownercredentials.go), new cases:
    • allow;
    • same owner, other session: the owner-keyed form allows it, the session-keyed form refuses it;
    • another owner, including one differing only in case;
    • a closed session gives denied, not session_closed, with the same error text as another owner;
    • a credential from before a close, after re-registering;
    • re-registering keeps the agent and its ag_ identifier;
    • expired, including with another owner or a closed session;
    • another signing key;
    • malformed requests, with an expired credential, so an invalid owner must be refused as denied before the credential would answer svid_expired.
  • TestVerifyCredentialChecks runs checks 1–7 through both forms: kid, alg, signature, audience, lifetime, and unregistered subject.
  • TestSessionHardExpiryClosesTheSession covers the owner-keyed form when it is the first lookup after the hard expiry.
  • Mutation checks: removing the "issued since the move", "open", hard-expiry, or owner-validation check each fails a test, and so does giving a closed session its own error text.

Local gates:

  • task lint: the root module and the modules linted before environment/microvm are clean. environment/microvm/launch_ownership_darwin.go:754 reports a gosec G703 finding on macOS; this branch doesn't touch that file. task lint stops at that module, so the modules after it weren't linted locally.
  • task docs:check: passes. The full task docs needs buf, which isn't installed locally.
  • go run ./cmd/mecademo: shows a tool call, a permission ask and approval, and a result.
  • task test:race: the identity broker packages, identityharness, and cmd/mecak8s pass. Other tests fail on this machine with or without this change:
    • in cmd/mecated: microVM socket path;
    • in cmd/mecatui: TLS key size and workspace snapshot;
    • in internal/adapter/server: placement cwd;
    • in internal/app: filesystem and git worktree tests.

API compatibility

No wire impact. CredentialVerifier is in-process only and served by no transport. Broker is its only implementer. No protobuf, mapper, or engine semantics change.

Follow-ups (not in this PR)

ChrisJBurns and others added 2 commits November 6, 2026 14:21
Add VerifyCredentialForOwner to CredentialVerifier, the check AS-1's
actor-token validator makes before issuing an ID-JAG: SVID checks 1-7,
then the instance's present broker session is open, owned by the given
Owner, and the credential was issued since the instance moved there.
It refuses only with svid_expired or denied, so no closing reason
reaches AS-1; any other error means the check could not be made.

Clarify check 8 at AS-1 in the design: the instance's session must be
open, as closing a session already ends its credentials' use.

Closes #2534

Co-authored-by: Mecatl <[email protected]>
Give every refusal after the SVID checks one detail text, so AS-1 cannot
tell a closed session from another owner's. Drop a scheduled-run claim
the design contradicts. Test an invalid owner with an expired credential,
so the request check is proven to run first, and move the case-differing
owner to the another-owner case.

Bring the remaining design passages about check 8 at AS-1 in line with
its open-session check: the failure matrix, the AS-1 test bullet, and the
notes on an AS-1 outside the broker.

Co-authored-by: Mecatl <[email protected]>
@ChrisJBurns
ChrisJBurns merged commit 866c507 into main Nov 6, 2026
47 checks passed
@ChrisJBurns
ChrisJBurns deleted the feat/identitybroker-owner-keyed-verify branch November 6, 2026 17:26
ChrisJBurns added a commit that referenced this pull request Nov 6, 2026
- Fail a test that leaves injected faults queued.
- Check that a sign-in gets the user it selected, and clear an unused
  selection when authorization fails.
- Test an expired client assertion just past its expiry: AS-1 allows no
  leeway.
- Split the test-only IdentityBrokerAS1 clock into the broker clock and
  the client-assertion clock, so the real-AS-1 test signs on wall time.
- Bound the shared AS-1 client to ten seconds per request.
- Keep #2733's VerifyCredentialForOwner row in the hard-expiry table.

Co-authored-by: Mecatl <[email protected]>
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Nov 18, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mecatl's actor-token validator

2 participants