Repository navigation
Conversation
AgentRequest is the one constructor of agenttoken.Request. It builds a request only for a call that came with a private app's token whose agent caps, read on every request, include deploying, a model or trust; the person and agent come from the token and its scope rides along. A browser session, a personal token, a job, a shared or non-agent app, or a request behind neither middleware gets ErrNoAgent. A source test fails if any other code writes an agenttoken.Request literal (one end-to-end broker test is exempt by its exact path). RequireAgentToken lets a mount outside /api/ take API tokens: it reads the bearer header only, checks the token as RequireUser does (known, not expired, still wanted, owner's sign-in recent), records its use, and gives the handler the same context RequireUser would, so AgentRequest answers the same on both mounts. A live non-agent token is passed on with no agent caps; a missing or dead one is 401 invalid_token. The Keycloak checks gain C12: a sign-in's session still refreshes after the second prompt=none request that collects the offline token. The spec records the owner's decision on admin roles behind the new mount. contracts.md, patterns.md and the plan's evidence, checkpoint review and deviations are updated.
This branch has not been 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.
Slice 14: AgentRequest and RequireAgentToken
Only a coding agent's own app token can make a broker request, for its owner, under
/api/and on a mount of its own, and the agent's token scope rides along.Spec: nebari-dev/tapas/docs/superpowers/specs/2026-11-30-agent-token-broker-design.md
Plan: nebari-dev/tapas/docs/superpowers/plans/2026-12-01-agent-tokens-and-frames.md (Slice 14)
Contracts touched:
authn.AgentRequest(the only constructor ofagenttoken.Request),authn.Authenticator.RequireAgentToken(middleware for a mount outside/api/)Depends on: #64
AgentRequest(ctx, service): only a private app token whose caps include Deploy, Model or Trusted (Q57), read per request; everything else isErrNoAgent.TokenScopecopied.agenttoken.Requestliteral outsideinternal/gateway/authn.RequireAgentToken: bearer only, the same liveness checks and context asRequireUser(compared for 11 token kinds); a live non-agent token passes with no caps (Q71); missing or dead is 401invalid_token.prompt=nonerequest.Validation
go test -count=1 -race ./internal/gateway/authn/... ./internal/gateway/agenttoken/...make test-local