Repository navigation
feat(identitybroker): carry the request's AS-1 token to broker session open - #2522
Merged
Merged
Conversation
…n open The authenticator attaches the bearer that verified the caller to the request context in a holder emptied when the request returns, on gRPC and HTTP. Server-owned work (plan continuations, auto-approve, retained approval contexts) has no token. The broker session open reads it once and passes it in OpenSessionRequest.AccessToken; the exchange is #2492. Refs #2488 Co-authored-by: Mecatl <[email protected]>
ChrisJBurns
marked this pull request as ready for review
October 26, 2026 15:20
authGRPC returned the static token and the identity bearer as adjacent strings, so swapping them would compile and could hand the static server token to the broker. The access token now has its own type. Co-authored-by: Mecatl <[email protected]>
… token A fire-now request creates the scheduled fire session inside the user's request, so its broker open read the user's AS-1 token. A scheduled session's authority comes from its schedule, not the user's sign-in. Refs #2488 Co-authored-by: Mecatl <[email protected]>
This was referenced Oct 26, 2026
jhrozek
approved these changes
Oct 26, 2026
jhrozek
approved these changes
Oct 26, 2026
jhrozek
left a comment
Contributor
There was a problem hiding this comment.
Approving. The token reaches every open made for a user request. Scheduled sessions and server-owned work get no token. The token never appears in logs, errors, snapshots, events, or model requests.
Non-blocking, fine as a follow-up:
- No test covers the strip in
autoApproveContinuation(service.go:8690). If you delete it, the suite stays green. The goroutine starts with the live request context (service.go:8636). So while a Converse stream is open, if the broker session had closed, the continuation would pass the user's bearer toOpenSession. A small internal test would close this gap: callautoApproveContinuationwith a token in the context, and check that the broker open gets a zero token.
For #2492:
- After
session_closed, the retry loop inopenIdentityBrokerSessionsends the same token to a second, new broker session. AS-1 will answertoken_usedthere. - The comment at
access_token.go:12-13("nothing else may read it") will need to change once schedule setup also needs the token.
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 #2488.
When a user request opens an identity broker session, the server now passes along the AS-1 access token that authenticated that request. Requests that don't come from a user (scheduler fires, server-owned plan continuations) carry no token.
What changes
authn.go): after a bearer passes identity verification, on the gRPC unary and stream interceptors and the HTTP middleware, it is wrapped inidentitybroker.Token(authGRPCreturns it as that type, so it can't be swapped with the static token) and stored in a request-scoped holder on the context. The holder is emptied when the request returns, so a context that outlives the request (detached withcontext.WithoutCancel, or kept by a run) no longer yields the token. The bearer is never re-read from metadata or headers, and the static server token is never carried.service.go):detachedControlContext, the auto-approve continuation, and saved exact-approval contexts strip the token. They act without a user request.identity_broker.go):openIdentityBrokerSessionreads the token once and setsOpenSessionRequest.AccessToken. This covers every open path: create, fork, clear, run entry (which also covers restore, since loading doesn't reopen), and team root. A scheduled session never takes the token, even when a user's fire-now request creates it inside that request: its authority comes from the schedule. The in-process broker ignores the field for now.internal/adapter/server/access_token.go.Scope against #2492
#2488 said putting the token into the open request belongs to #2492. Setting the field here is what lets the tests prove the token reaches every open. The exchange, and the decision about when a token is spent (the open loop can call
OpenSessiontwice in one request, and AS-1 accepts each token only once), stay with #2492.Testing
Servicecalls with only a principal, and contexts kept after a unary, stream, or HTTP request returned all open with a zero token. The kept contexts still hold the principal, which shows the holder was emptied and the principal kept.go test -raceon the focused server tests;cmd/mecak8s,internal/identitybroker, andinternal/appbroker tests pass.TestACPUsesHostGovernanceRootAndClosesRejectedBindingandTestLoadACPSessionOwnsExactBindingUntilOverrideLifecycleEndsfail the same way on main in the local sandbox ("cwd does not match the configured session placement"). Lint reports a staticcheck SA5011 atservice.go:3256, on a line this PR doesn't touch.task lint && task test:racegate.API compatibility
Assessment: compatible; no wire change and no major bump. No proto, HTTP body, status, or engine API change. The token goes only to the in-process identity broker, which ignores it for now. Nothing about it is visible to clients.
Upgrade implications: none.