Skip to content

feat(identitybroker): check AS-1's actor tokens with the broker's verifier - #2840

Merged
ChrisJBurns merged 3 commits into
mainfrom
feat/identitybroker-as1-actor-validator
Nov 18, 2026
Merged

ChrisJBurns merged 3 commits into
mainfrom
feat/identitybroker-as1-actor-validator

Conversation

@ChrisJBurns

Copy link
Copy Markdown
Contributor

Second PR of #2654: hosted AS-1 can issue per-call ID-JAGs to the identity broker's delegate client, checking each actor token with the broker's CredentialVerifier. Builds on #2838 (ToolHive v0.66.0, merged).

What

AS-1's actor-token validator (internal/identitybroker/adapter/as1server), design step (7) check 6:

  • DelegateClient.IDJAG (optional) configures the targets the broker may request ID-JAGs for and act.iss. When set, AS-1 registers the validator with ToolHive (WithActorTokenValidators), and the delegate client gets an actor profile pinned to the JWT actor-token type and ID-JAG targets that require sub_id and upstream_subject. Nil keeps today's behaviour.
  • The validator reads the grant's owner from its RFC 9493 sub_id with session open's rule, asks VerifyCredentialForOwner, and answers:
    • allowed: act.sub = the broker's ActorID (spiffe://<trust domain>/agent/<ag_>), the credential's expiry (ToolHive caps the ID-JAG's exp at it), and the SVID's SPIFFE ID for AS-1's audit;
    • expired credential: actor_token_expired; any other broker refusal or another client: denied;
    • anything else (verifier not bound yet, broker outage, missing sub_id, an agent outside act.iss): a plain error, which AS-1 answers as a retryable 500 server_error with nothing revoked.
    • AS-1 gets only the reason code: errors carry fixed text, never the broker's error, a user identifier, or a token (ToolHive logs validator errors at Warn).
  • Server.UseCredentialVerifier binds the verifier after AS-1 is built, since internal/app builds AS-1 before the broker. It binds once.
  • act.iss must be spiffe://<trust domain>; ToolHive refuses AS-1's own issuer. Values follow docs(agent-identity): set act.iss to the agent trust domain and make agent SPIFFE IDs opaque #2834.

Broker core (internal/identitybroker):

  • OwnerFromSubjectIdentifier: the iss_sub parsing factored out of session open, now shared with AS-1. Session open behaves the same.
  • VerifiedAgent.ActorID: the agent's name in act.sub, owned by the broker so the adapter doesn't build it. The validator refuses (plain error) an ActorID outside act.iss, so a mismatch between act.iss and the broker's trust domain fails closed.
  • ValidateTrustDomain exported for the act.iss check.

depguard: as1server may import the broker core and ToolHive's tokenexchange (the interface it implements).

Not in this PR (PR 3 of #2654): registering the real broker in internal/app with act.iss from the broker's trust domain, configuring the target through the test-only gateway settings, and retiring the harness AS-1's ID-JAG issuance and the UseCredentialVerifier hook in internal/app.

Tests

Against the real AS-1 with a fake verifier (actorvalidator_test.go):

  • the ID-JAG names the agent in a single-level act (iss = act.iss, sub = ActorID), carries sub_id and upstream_subject, expires no later than the credential, and its signature verifies; the verifier gets the grant's owner and the exact actor token;
  • expired → actor_token_expired; denied (another user's session, a closed session, an untrusted credential) → denied; outage → 500, and the same grant works afterwards;
  • an accepted answer that expired 2 minutes ago, or with no expiry → 500; 10 seconds ago → actor_token_expired;
  • verifier not bound → 500, then works once bound;
  • a missing actor token or another actor-token type is refused without calling the verifier;
  • no response contains the broker's error text;
  • target lifetime: configured and default;
  • configuration: act.iss forms, no targets, fractional lifetime, a target at AS-1's own issuer;
  • the mapping table directly, including missing or malformed sub_id, another client, a wrapped refusal, an empty ag_, and an agent outside act.iss.

Core: TestOwnerFromSubjectIdentifier; ActorID checked in the credential conformance suite and against the configured trust domain.

Not tested here: a grant without sub_id reaching AS-1. The hosted AS-1 records sub_id for every grant the broker can open, so this fixture can't produce one. ToolHive refuses such a grant with sub_id_missing before calling the validator (its own tests pin the order).

Mutation-checked: the failure mapping (expired, denied, plain error), the client restriction, the act.iss guard, the empty-ag_ guard, the lifetime, and the required subject claims.

Checks

  • task lint: 0 issues; task docs:check: passes.
  • go test -race ./internal/identitybroker/... ./internal/testutil/identityharness/... and the internal/app and cmd/mecak8s identity broker tests: pass.
  • Root module (GOWORK=off -mod=readonly -race ./...): passes except deploy/helm/mecatl-execution and deploy/mecatl-execution-kind, which fail identically on main in this environment (local Helm and shell tooling).

Issue relationship

Part of #2654

API compatibility

None: internal packages only, no wire or public API change.

ChrisJBurns and others added 2 commits November 17, 2026 19:31
…ifier

Hosted AS-1 can issue per-call ID-JAGs to the broker's delegate client
(design step (7), check 6). When DelegateClient.IDJAG is set, AS-1
registers a validator that reads the grant's owner from its sub_id and
asks the broker's CredentialVerifier: an expired credential is
actor_token_expired, any other refusal denied, and anything else a plain
error that AS-1 answers as a retryable server_error. AS-1 sees only the
reason code. The verifier is bound after AS-1 is built.

The broker owns the agent's act.sub as VerifiedAgent.ActorID, and the
sub_id parsing moves out of session open so both share one rule.

Part of #2654.

Co-authored-by: Mecatl <noreply@mecatl.dev>
…leaf

The validator implements ToolHive's ActorTokenValidator, so its file
imports tokenexchange, like the other as1server files the boundary test
approves.

Co-authored-by: Mecatl <noreply@mecatl.dev>

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. The validator follows ToolHive's contract, the owner check ties the grant to the agent, and error text stays free of user identifiers and tokens. Two small inline comments, neither blocking.

Comment thread internal/identitybroker/sessionopen.go Resolved
…ntract

AS-1's actor validator answers denied only for the verifier's denied
refusal, as CredentialVerifier promises; any other error is a check that
could not be made and stays retryable. OwnerFromSubjectIdentifier reads
format, iss, and sub by exact name, so a differently cased member never
stands in for sub and it agrees with authn/oidc on the owner.

Co-authored-by: Mecatl <noreply@mecatl.dev>
@ChrisJBurns
ChrisJBurns merged commit 3828859 into main Nov 18, 2026
49 of 50 checks passed
@ChrisJBurns
ChrisJBurns deleted the feat/identitybroker-as1-actor-validator branch November 18, 2026 15:28
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.

2 participants