Repository navigation
fix(api): hold a person's token to its scopes on an expand that reads another resource - #3547
Merged
Merged
Conversation
…ay call A person's token is meant to reach what a Console session of theirs reaches, but handleAccessToken read userBoundSessionOperations, a list kept for anonymous cookies, and five operations that take both a session cookie and a bearer were missing from it: listInvitations, getInvitation, cancelInvitation, getApplicationRevision and evaluatePolicy. They join it, the two invitation reads join projectReads, and a test now holds the list to the spec. createInvitation stays off it by a decision the test names: its answer is a link that gives a role, and a person's token reaches no operation that answers with a credential. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
The exception kept a person's token off createInvitation because its answer is a link that gives a role. The credential and its scopes decide what a caller may do, so the exception goes: a person's token reaches every operation that takes both a session cookie and a bearer, and the test holds the list to the spec without exceptions. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…s token A person's token on the management API has not been released, and its pending changeset already says the token reaches the operations a Console session may call (.changeset/README.md). It now also says project.read reads a project's invitations. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
A review found that a token with only project.read read each inviter's user ID and email through expand=inviter on the invitation list, now that the list takes a person's token. An inviter is a user, and a token's scopes are a ceiling the person's grants do not lift, so the expand asks for user.read as the other expands ask for their scope. ADR 092 also counted three reads under project.read where there are five. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
The invitation operations named project.write, the scope that renames a project. Once a person's token reached them, a client a project administrator had allowed to change a project could create an admin invitation, whose link anyone signed in redeems, while createGrant on the same token is refused without grant.create. An invitation ends in a grant and its gate asks what creating a grant asks, so createInvitation names grant.create, the two reads grant.read and cancelInvitation grant.delete. A project secret is unaffected: its project.write covers every scope. This answers the permission catalog's open question on project invitations. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…ations' into claude/search-token-scopes # Conflicts: # apps/api/internal/api/integration_test/access_token_test.go
search names one scope, the project's, and checked no other. A token issued for a person with project.read alone found users by name or identifier, teams, schemas, flow definitions and identity providers, whatever the token was consented to. Each type search is to find now asks of such a token the read scope that type's own list names, and a token without it is refused with auth.scope_insufficient, naming the scope, before anything is read. A session and a project secret have no such ceiling and search as before. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Picks up #3545, which the PR stacked on this branch (#3546) already holds, so that PR's diff shows only its own change. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…-scopes Takes the base's merge of main, so this PR's diff against its base is its own change. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
createInvitation with replaces_invitation_id deletes the original, and one that sends no metadata answers with the original's. A person's token issued with grant.create alone could so cancel an invitation that cancelInvitation refuses it, and read a name getInvitation refuses it. A replace now asks grant.delete of such a token, and grant.read when it carries the metadata over. A Console session and a project secret are unaffected. The contract test's open note on invitation reads named the catalog's old home for invitations; it now names the grant scopes. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…-scopes Takes the base's fix for an invitation replace; the changeset keeps both branches' sentences. ADR 092 §8 also says that the tool list shows search to a token with project.read alone, and that a call for a type the token does not cover is refused with the scope it lacks. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
… another resource An expand reads a resource beside the operation's own. Three of the seven the API declares checked no scope of a token issued for a person: a grant's principal (a user's schema, attributes and metadata, on a token with grant.read alone), a schema's in_use and a flow definition's user_schema. getUser refuses the first token for lack of user.read. Every expand now names the scope of what it reads in one table, and the three ask it of such a token, as an invitation's inviter already did. A test holds the table to the spec's expand enums, so a new expand names its scope. A Console session and a project secret have no ceiling and are unaffected. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
🦋 Changeset detectedLatest commit: a93db7e The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Picks up #3537, which landed on main first. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
#3538 landed on main as one commit. This branch already holds its changes through the old base branch, so the merge takes nothing from it: it only records main as an ancestor, so that the pull request shows its own change. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
The base branch had main merged in before it landed; this takes those merges, so that main's squash of #3538 is an ancestor here too. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…cope Picks up what landed on main in between: #3541, #3539, #3543 and #3542. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
#3546 landed on main as one commit. This branch already holds its changes through the old base branch, so the merge takes nothing from it: it only records main as an ancestor, so that the pull request shows its own change. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
fforootd
pushed a commit
that referenced
this pull request
Dec 2, 2026
Picks up #3546 and #3547, which landed after #3542. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
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.
Context
expand=invitercheck.Summary
The gap: an
expandreads a resource beside the operation's own. The API declares seven; three checked no scope of a token issued for a person:queryGrants,getGrantprincipalschema,attributesandmetadata, on a token withgrant.readaloneuser.readlistSchemasin_useuser.readlistFlowDefinitionsuser_schemaflow_definition.readaloneschema.readgetUserrefuses the first token for lack ofuser.read. ADR 092 §8 already said a token needs the scope where a session's grants waive it on an expanded read; the schema expand's description already promiseduser.readof a token.The fix: every expand names the scope of what it reads in one table,
expandScopes.requireExpandCeilingrefuses the expand to a person's token without that scope, with403 auth.scope_insufficientnaming the scope, before anything is read. The three expands above call it, and so does an invitation'sinviter, which fix(api): take a person's token on the operations a Console session may call, and guard invitations with the grant scopes #3538 had checked inline.The guard:
TestEveryExpandNamesTheScopeItReadsholds the table to the spec's<resource>-expandenums, and each scope to one a person's token can carry. A new expand fails it until it names its scope; an expand the table does not know is refused to such a token.Who is unaffected: a Console session and a project secret have no ceiling here. The check of what the caller may read (the principal's home project, the whole project for
in_use) still runs after it.The other four expands (
teamsandlifecycle_owner_teamon users,releaseon deployments,inviteron invitations) already held a person's token to the scope; they are in the table and their code is unchanged, apart frominviterusing the shared check.Docs: the grant and flow definition expand descriptions, ADR 092 §8, the OpenAPI
AGENTS.mdand the pending changeset say it.Validation
go test ./internal/api/ ./internal/mcp/ ./internal/service/passes, with two new tests:TestEveryExpandNamesTheScopeItReadsandTestRequireExpandCeiling.go test -tags sqlite_integration ./internal/api/integration_test/passes, with a newTestAccessTokenExpandsWithinItsScopesagainst the real API with real tokens: each of the four calls answers403 auth.scope_insufficientnaming the scope without it, and200with it. All four cases fail with the handler changes stashed (the first call answers200).turbo run generatefor@zitadel/serverand@zitadel/api,pnpm run check-openapi-rules, the toolchain'sgofmt,go vetwith and without the integration tag,scripts/go-lint.mjsandscripts/check-pr-title.mjspass.Release notes / changeset
.changeset/api-person-token.md(@zitadel/server,@zitadel/api, minor), as.changeset/README.mdasks for a fix to a change that has not been released: a person's token on the management API is unreleased.Notes
expand, a grant list still shows each grantee'suser_id,identifieranddisplayto a token withgrant.read, and a project's member list does to one withproject.read. That is what those lists are for.https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Generated by Claude Code