Repository navigation
fix(identitybroker): read AS-1's named reasons for refused subject tokens - #2625
Merged
Merged
Conversation
…kens AS-1 refuses a session-open subject token with subject_token_invalid when a fresh access token can pass, or subject_token_audience / subject_token_source_client for configuration faults, and an unknown grant with grant_invalid (agreed on toolhive#7003). The broker maps subject_token_invalid to subject_invalid; the other three are known reasons classified as configuration faults; a reasonless invalid_request is now a broker bug or configuration fault rather than a subject problem. The offline harness sends subject_token_invalid as ToolHive does. Co-authored-by: Mecatl <[email protected]>
jhrozek
approved these changes
Oct 30, 2026
Merged
2 tasks
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
Aligns the identity broker with the reasons ToolHive's AS-1 token exchange sends for a refused subject token at session open, as agreed on stacklok/toolhive#7003 and recorded in the design catch-up #2616.
subject_token_invalid(a fresh access token can pass) →subject_invalid: the server answers the taggedbearer_rejected401, and the client refreshes and retries once.subject_token_audience,subject_token_source_client(configuration faults) andgrant_invalid(unknown or expired grant) → known reasons, classified as configuration faults →INTERNAL.invalid_requestwith no reason, or AS-1 sending the broker's ownsubject_invalid, is no longer read as a subject problem: it is a broker bug or configuration fault →INTERNAL. Matching a named reason is sturdier than reading meaning into a missing one.subject_token_invalidfor every check 4 refusal, as ToolHive does. It does not tell the two configuration-fault reasons apart (the audience check happens inside JWT parsing, and a token can fail several checks); the broker's own tests cover them.Issue relationship
Relates to #2492, #2616, stacklok/toolhive#7003
API compatibility
No protobuf or handler change. The only client-observable difference is under the experimental
--enable-identity-brokerwith AS-1 conversion configured (app.Config.IdentityBrokerAS1, set by no deployment until #2607): a reasonlessinvalid_requestfrom AS-1 at session open now reaches clients asinternalinstead ofbearer_rejected. Additive otherwise; no major or feature change.Test plan
go test -raceoninternal/identitybroker/...,internal/testutil/identityharness,cmd/mecak8s, the server's identity broker tests, andinternal/appidentity broker testssubject_token_invalidmapping, or mapping a reasonlessinvalid_requesttosubject_invalidagain, fails the mapping teststask lint: clean except the pre-existing gosec finding inenvironment/microvm/launch_ownership_darwin.go