Repository navigation
test(identityharness): add broker client auth, session open, and revocation to AS-1 - #2524
Merged
Merged
Conversation
…cation to AS-1 The offline AS-1 stand-in now authenticates the identity broker as the confidential client mecatl with private_key_jwt, converts a sign-in access token into a session-bound, non-rotating refresh token through RFC 8693 token exchange with the design's checks and refusal reasons, refuses that token at the refresh grant, and revokes it (RFC 7009), closing the session. Faults (error, lost response, mismatched echo, hard expiry) and state queries let the broker work build and test against it offline. Design guesses are marked in the code. Closes #2494. Co-authored-by: Mecatl <[email protected]>
1 of 14 tasks
jhrozek
approved these changes
Oct 26, 2026
Merged
2 tasks
This branch was successfully deployed
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.
Closes #2494.
The offline harness's stand-in AS-1 can now do what the sign-in slice needs next: authenticate the identity broker, convert a sign-in into a session-bound refresh token, and revoke it. #2489 (broker client authentication), #2492 (session-open conversion), and #2493 (reopen) can build and test against it before the ToolHive work lands.
Test code only (
internal/testutil/identityharness/); no production code changes.What changes
mecatlthat authenticates withprivate_key_jwt. It checksiss=sub=mecatl,audequal to AS-1's issuer as the only value,exp - iatwithin the maximum (60 s by default), a single-usejti,iat/exp/nbf, a stringkidnaming a registered key, ES256 only, and refusesclient_secretand Basic authentication. Tests can mint assertions with each defect, and production code under test registers its own key throughOptions.BrokerKeys.invalid_client,unauthorized_client,invalid_request/invalid_scope/invalid_authorization_details,subject_invalid,owner_mismatch,session_owned,token_used), and a retry after a lost response is accepted. Themecatl_sessionentry is parsed strictly: member names must be exact and appear once.invalid_grantthere; a public client cannot use token exchange.revoke.go): RFC 7009, broker only; revoking the current token closes the session, and a closed session cannot be opened again (session_owned).FailNextSessionOpen(a 503 or any error),LoseNextSessionOpenResponse(processed, then the connection drops),MismatchNextSessionOpenEcho,ExpireSession(or the injectable clock), and queries for a session's refresh token, refusals, and closed state.h.ScriptedBroker(): a hand-driven caller holding the broker's credentials, for driving AS-1 directly in tests. It is deliberately not named like the production broker; production code under test uses its own client.private_key_jwt, the token-exchange grant, and the revocation endpoint; public clients keepnone, so mecatui sign-in is unchanged.Design guesses
Where the design is silent, the code marks each choice with
// Guess:, also listed in the package doc, so they can be checked against ToolHive (stacklok/toolhive#6886, #6893, #6895, #6897) when it lands:{issuer}/revoke, broker only; revoking a replaced or unknown token returns 200 and changes nothing.mecatl_sessionentry are accepted and echoed unchanged.JWT(golang-jwt's default) or untyped is accepted, as isclient-authentication+jwt; the production broker's own tests must check thetypit emits.expires_inis the time left until it.supersededis not offered as a session-open fault: the design returns it only to an exchange presenting a replaced refresh token, which is the later ID-JAG exchange.Testing
invalid_grant, revocation, closed sessions, hard expiry, every client-assertion defect (wrongaud, expired, too long, reused or missingjti, missingiat/exp/kid, futureiat,alg: none, HS256, foreign key,client_secret), invalidBrokerKeysoptions, and each fault.go test -raceon the harness andcmd/mecak8s(its existing user);go vet; the offline demo.task lintis clean except the existing gosec finding inenvironment/microvm/launch_ownership_darwin.go.API compatibility
No wire, engine API, or stored-data change: test infrastructure only.