Repository navigation
test(identityharness): re-cut AS-1 to the generic grant - #2589
Merged
Merged
Conversation
Bring the merged identity broker code to the current design, where AS-1 issues generic grants bound to the client and the user (design PR #2575). The offline harness's AS-1 now exchanges an access token for a grant that issues only ID-JAGs: one exchange-grant entry with a capped, echoed expires_at, one grant per access-token jti with no retry exception, no session, owner, or replacement logic, and no reason for a refused access token. knownReasons gains revoked, parent_revoked, and not_issuable and drops superseded, so a revoked grant is not taken for a configuration fault. Part of #2492. Co-authored-by: Mecatl <noreply@mecatl.dev>
Design PR #2587 makes the broker resend a lost session-open request once, with the same access token and a new client assertion. The ErrNoResponse note applies at session open again, and the lost-response tests become two cases: a resend after a processed request gets token_used, and a resend of a request AS-1 never processed converts. DropNextExchange injects the second case. Co-authored-by: Mecatl <noreply@mecatl.dev>
This was referenced Oct 29, 2026
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.
Summary
First step of #2492: brings the merged identity broker code to the current design. Design PR #2575 made AS-1's grants generic after #2494 and #2489 merged. No broker behaviour changes; the broker side of session open follows in its own PR.
internal/testutil/identityharness): session open is now the exchange for a generic grant, as Refresh tokens through token exchange, as generic grants toolhive#6897 builds it.id-jag. Its optionalexpires_atis capped at AS-1's maximum (Options.GrantMaxLifetime) and echoed.jti, with no retry exception.resourceandaudienceare refused withinvalid_target, and unknown entry members are refused.invalid_authorization_detailscarries ToolHive's sub-reasons.revoked.DropNextExchange, drops a request before AS-1 processes it, besideLoseNextExchangeResponsefor one it processed. Replay-revoke (Revoke the grant a reused subject token created toolhive#6973) is phase 2, so a reusedjtiis refused but revokes nothing.knownReasons(internal/identitybroker/serverrefusal.go): addsrevoked,parent_revoked, andnot_issuableand dropssuperseded, so a revoked grant is not reported as a configuration fault.invalid_requesttosubject_invalidbeforeIsConfigurationFault. Following design PR docs(agent-identity): reconcile the ToolHive work list and settle the lost-response rule #2587,ErrNoResponse's "retry once" note applies at session open: the resend carries the same access token, and atoken_usedrefusal means the client must refresh and open again.authserverclienttests: use the exchange-grant entry. After a lost response, a resend of a request AS-1 processed getstoken_usedand a fresh token converts; a resend of a request it never processed converts. A refused access token gets no reason.Not in this PR: child grants. The harness can't yet produce
parent_revoked; that comes with ID-JAG issuance and #2569.Issue relationship
Part of #2492
API compatibility
None. Test harness and internal classification only: no protobuf, server, or client change. Production code receives none of the new reasons yet, because nothing wires AS-1 into the broker.
Test plan
go test -raceoninternal/testutil/identityharness,internal/identitybroker/...,cmd/mecak8s, andinternal/adapter/clientauthrevokedremoved fromknownReasons, and a dropped request that AS-1 processes anyway each fail the new teststask lint: clean except a pre-existing gosec finding inenvironment/microvm/launch_ownership_darwin.go(untouched)task test:race: failures incmd/mecated,cmd/mecatui,environment/microvm/gitexec,internal/app, andinternal/adapter/serverall reproduce on unmodifiedorigin/mainon this machinego run ./cmd/mecademo)