Repository navigation
feat(identitybroker): check AS-1's actor tokens with the broker's verifier - #2840
Merged
Merged
Conversation
…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>
This was referenced Nov 17, 2026
jhrozek
approved these changes
Nov 18, 2026
jhrozek
left a comment
Contributor
There was a problem hiding this comment.
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.
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 andact.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 requiresub_idandupstream_subject. Nil keeps today's behaviour.sub_idwith session open's rule, asksVerifyCredentialForOwner, and answers:act.sub= the broker'sActorID(spiffe://<trust domain>/agent/<ag_>), the credential's expiry (ToolHive caps the ID-JAG'sexpat it), and the SVID's SPIFFE ID for AS-1's audit;actor_token_expired; any other broker refusal or another client:denied;sub_id, an agent outsideact.iss): a plain error, which AS-1 answers as a retryable 500server_errorwith nothing revoked.Server.UseCredentialVerifierbinds the verifier after AS-1 is built, sinceinternal/appbuilds AS-1 before the broker. It binds once.act.issmust bespiffe://<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: theiss_subparsing factored out of session open, now shared with AS-1. Session open behaves the same.VerifiedAgent.ActorID: the agent's name inact.sub, owned by the broker so the adapter doesn't build it. The validator refuses (plain error) anActorIDoutsideact.iss, so a mismatch betweenact.issand the broker's trust domain fails closed.ValidateTrustDomainexported for theact.isscheck.depguard:
as1servermay import the broker core and ToolHive'stokenexchange(the interface it implements).Not in this PR (PR 3 of #2654): registering the real broker in
internal/appwithact.issfrom 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 theUseCredentialVerifierhook ininternal/app.Tests
Against the real AS-1 with a fake verifier (
actorvalidator_test.go):act(iss=act.iss,sub=ActorID), carriessub_idandupstream_subject, expires no later than the credential, and its signature verifies; the verifier gets the grant's owner and the exact actor token;actor_token_expired; denied (another user's session, a closed session, an untrusted credential) →denied; outage → 500, and the same grant works afterwards;actor_token_expired;act.issforms, no targets, fractional lifetime, a target at AS-1's own issuer;sub_id, another client, a wrapped refusal, an emptyag_, and an agent outsideact.iss.Core:
TestOwnerFromSubjectIdentifier;ActorIDchecked in the credential conformance suite and against the configured trust domain.Not tested here: a grant without
sub_idreaching AS-1. The hosted AS-1 recordssub_idfor every grant the broker can open, so this fixture can't produce one. ToolHive refuses such a grant withsub_id_missingbefore calling the validator (its own tests pin the order).Mutation-checked: the failure mapping (expired, denied, plain error), the client restriction, the
act.issguard, 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 theinternal/appandcmd/mecak8sidentity broker tests: pass.GOWORK=off -mod=readonly -race ./...): passes exceptdeploy/helm/mecatl-executionanddeploy/mecatl-execution-kind, which fail identically onmainin this environment (local Helm and shell tooling).Issue relationship
Part of #2654
API compatibility
None: internal packages only, no wire or public API change.