Repository navigation
fix(api): take a person's token on the operations a Console session may call, and guard invitations with the grant scopes - #3538
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 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. |
🦋 Changeset detectedLatest commit: ad7f798 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 |
There was a problem hiding this comment.
🟡 Changes recommended
The follow-up adds a separate release note instead of updating the existing pending changeset, contrary to repository policy.
1 open issue
What changed in this PR
Extends person-token access to five management API operations already available to Console sessions, while keeping invitation creation excluded.
Changes:
- Enables the five operations and uses
project.readfor invitation reads. - Adds a spec-based test guarding session/token operation parity.
- Documents the exception and release impact.
| File | Description |
|---|---|
docs/adrs/092-mcp-server.md |
Documents the invitation-creation exception. |
apps/api/internal/api/security.go |
Expands token access and invitation read-scope mapping. |
apps/api/internal/api/security_access_token_test.go |
Checks operation parity and explicit exceptions. |
.changeset/person-token-session-operations.md |
Adds a server release note. |
Review effort: Balanced
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
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
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
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
Picks up what landed on main in between: #3538, #3541, #3539 and #3543. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U

Context
Summary
handleAccessTokendecides whether a person's token may call an operation byuserBoundSessionOperations. That list was kept for another purpose: which operations skip an anonymous building cookie. Six operations take both a session cookie and a bearer but were missing from it, so the Console could call them and a person's token could not:createInvitation,listInvitations,getInvitation,cancelInvitationgetApplicationRevisionevaluatePolicyproject.write, the scope that renames a project. A client a project administrator had allowed to change a project could then have created anadmininvitation, whose link anyone signed in redeems for 72 hours, whilecreateGranton the same token is refused withoutgrant.create. An invitation ends in a grant and its gate asks what creating a grant asks, so:createInvitationnamesgrant.create;listInvitationsandgetInvitationnamegrant.read;cancelInvitationnamesgrant.delete, so it leaves the list of removals on a write scope inscripts/openapi-casing-rules.test.mjs.project.writecovers every scope.createInvitationwithreplaces_invitation_iddeletes the original, and one that sends nometadataanswers with the original's. Of a person's token it therefore needsgrant.deletebesidegrant.create, andgrant.readwhen it carries the metadata over. Otherwise a token withgrant.createalone would cancel an invitation thatcancelInvitationrefuses it. Found by an independent review of this PR.user.read:expand=inviteron the invitation list answers403 auth.scope_insufficientto a token withoutuser.read. An inviter is a user, and a token's scopes are a ceiling the person's grants do not lift, as on the other expands.TestAPersonsTokenReachesWhatASessionReachesholds every operation the spec lets both a session cookie and a bearer call to the list.adminon the project (ADR 086),getApplicationRevisionandevaluatePolicyaskviewer. A token's scopes cap the person's own grants.createInvitationbecomes a tool with feat(api): offer an MCP client the operations that answer with a credential #3542.Validation
TestAPersonsTokenReachesWhatASessionReachesfails onmainnaming the missing operations, and passes with the fix.go test ./internal/api/ ./internal/mcp/passes. That covers the gate contract with anonymous cookies,TestEveryOperationAPersonsTokenReachesNamesAScope,TestAPersonsTokenReadsTheProjectWithTheReadScopeandTestPersonScopesAreScopesAPersonsTokenCanUse.go test -tags sqlite_integration ./internal/api/integration_test/passes, with a newTestAccessTokenWorksOnInvitationsWithTheGrantScopes:project.writewithproject.readcreates no invitation and lists none;grant.createcreates one,grant.readreads it, and onlygrant.deletecancels it;grant.createwithgrant.read, and withoutmetadataongrant.createwithgrant.delete; the original is still there after both, and the replace passes withgrant.deleteand its ownmetadata(this part fails without the fix);expand=inviterneedsuser.readas well.turbo run generatefor@zitadel/serverand@zitadel/api: the bundled spec, the generated security and handler code and the Go client changed with the scopes.pnpm run check-openapi-rulespasses.turbo run lint --filter=@zitadel/server --continue: 14 of 15 tasks pass.formatfails oninternal/flowengine/sso_test.go, which this PR doesn't touch: the container'sgofmtis older than the toolchain, and the toolchain's own is clean.node scripts/check-pr-title.mjspasses.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. It now says the invitation operations name the grant scopes, and that a project secret is unaffected.Notes
mainis merged in (test: serve SDK session tests from the shared Flow API mock #3545) so that fix(api): hold a person's search to the types its token's scopes cover #3546, stacked on this PR, shows only its own change.main, not fixed here:expand=principalon the grant lists checks no scope, so a person's token withgrant.readalone reads each grantee's attributes and metadata, whichgetUserrefuses it withoutuser.read./users/me/*reads accept only a session cookie. ADR 094 (docs: decide the project permission model under the platform root #3539) decides how these open.searchstill checks no per-type scope here: a token with onlyproject.readfinds users, teams and identity providers through it. That is onmain; fix(api): hold a person's search to the types its token's scopes cover #3546, stacked on this PR, fixes it.https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Generated by Claude Code