Skip to content

fix(api): hold a person's search to the types its token's scopes cover - #3546

Merged
fforootd merged 14 commits into
mainfrom
claude/search-token-scopes
Dec 2, 2026
Merged

fforootd merged 14 commits into
mainfrom
claude/search-token-scopes

Conversation

@fforootd

@fforootd fforootd commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Context

Summary

  • The gap: 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 person had consented the client to. ADR 092 §8 says a token's scopes are a ceiling the person's grants do not lift; search did not hold to it.

  • The fix: each type search is to find asks of such a token the read scope that type's own list names:

    Type Scope
    user user.read
    team team.read
    schema schema.read
    flow_definition flow_definition.read
    idp idp.read
  • Refused, not left out: a token without the scope gets 403 auth.scope_insufficient, which names the scope it lacks, before anything is read. Leaving the type out would let an agent read an empty result as "there is none".

  • A type without a scope is refused to a person's token, so a new result type is never searched before it has one.

  • Who is unaffected: a Console session and a project secret have no such ceiling and search as before. search already lists auth.scope_insufficient among its errors, so the contract's error list does not change.

  • Docs: the operation's description, ADR 092 §8 and the pending changeset say it.

Validation

  • go test ./internal/api/ ./internal/mcp/ passes, with two new tests:
    • TestSearch_APersonsTokenSearchesTheTypesItsScopesCover: a token with project.read alone is refused users; a session is not.
    • TestSearchReadScopesAreTheListsOwn: every result type in the spec has a scope, and it is the one its list names.
  • go test -tags sqlite_integration ./internal/api/integration_test/ passes, with a new TestAccessTokenSearchesWithinItsScopes against the real API with real tokens. It fails on main without the fix (the first call answers 200).
  • turbo run generate for @zitadel/server and @zitadel/api, pnpm run check-openapi-rules, the toolchain's gofmt, go vet with and without the integration tag, scripts/go-lint.mjs and scripts/check-pr-title.mjs pass.
  • Not run: the Postgres and Spanner lanes. Nothing here touches storage.

Release notes / changeset

  • Changeset: edits the pending .changeset/api-person-token.md (@zitadel/server, @zitadel/api, minor), as .changeset/README.md asks for a fix to a change that has not been released: a person's token on the management API is unreleased.

Notes

https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U


Generated by Claude Code

…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
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cloud Ready Ready Preview Dec 2, 2026 5:39am UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-12-02T04:08:00.759508Z 16589ac PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: c957b67

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@zitadel/server Minor
@zitadel/api Minor
@zitadel/cli Minor
@zitadel/components Minor
@zitadel/config Minor
@zitadel/sdk-angular Minor
@zitadel/sdk-core Minor
@zitadel/sdk-next Minor
@zitadel/sdk-nuxt Minor
@zitadel/sdk-qwik Minor
@zitadel/sdk-react Minor
@zitadel/sdk-solid Minor
@zitadel/sdk-svelte Minor
@zitadel/sdk-tanstack-start Minor
@zitadel/sdk-vue Minor
@zitadel/testing Minor
@zitadel/cloud Patch
@zitadel/client-sdk-contract Patch
@zitadel/sdk-qwik-router Minor
@zitadel/sdk-solid-start Minor
@zitadel/sdk-sveltekit Minor
@zitadel/server-sdk-contract Patch
@zitadel/server-darwin-arm64 Minor
@zitadel/server-darwin-x64 Minor
@zitadel/server-linux-arm64 Minor
@zitadel/server-linux-x64 Minor
@zitadel/server-win32-x64 Minor

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 #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
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
Merged via the queue into main with commit 2bdd5a6 Dec 2, 2026
17 of 18 checks passed
@fforootd
fforootd deleted the claude/search-token-scopes branch December 2, 2026 05:51
@github-project-automation github-project-automation Bot moved this from Inbox to Done in Engineering Kanban Dec 2, 2026
fforootd pushed a commit that referenced this pull request Dec 2, 2026
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
fforootd pushed a commit that referenced this pull request Dec 2, 2026
…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
fforootd pushed a commit that referenced this pull request Dec 2, 2026
#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

1 active deployment
Preview — c957b67f Deployed Dec 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants