Repository navigation
feat(api): let a person's token read who they are and which projects they can act on - #3559
Conversation
…they can act on An agent signed in to the MCP endpoint as a person could not ask who it acts for or which projects that person can work on: the /users/me reads took only a session cookie (ADR 094 §6, step 1 of §12). - getMyUser, listMyProjects, listMyTeams, getMyUserSchema, listMyPasskeys, listMyIdentityLinks and getMyPasswordState take a token issued for the person, each under the read scope of what it returns (user.read, project.read, team.read, schema.read). Without it the token is refused with 403 auth.scope_insufficient naming the scope. The token is held to its project as a session is (sess.project_mismatch). - A project secret is no person: on these reads the API passes over it before looking at it, so it is answered exactly as before, as a request without a credential, and the MCP endpoint shows it none of their tools. - The spec marks a person's own operations x-zitadel-self. The CLI, which holds a project secret, refuses them with a reason, and the docs' sample for their bearer branch is a person's token, never a project secret. - Their tools take no project_id: that parameter holds a browser's session to the project of the app that sends the cookie, which a bearer never needs, and an agent would read it as the project to act on. - The endpoint's instructions tell an agent signed in as a person to start with getMyUser, then listMyProjects. - The tool list's budget grows by the seven tools' 5,142 bytes. A project secret is still shown 79 tools (141,563 bytes); a person's token with every scope 65 (88,512). - The 403 of the seven is now an error with a code in the Go client, in place of SessProjectMismatch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmTvJjKuUM2VnUUGH9Y
getMyUser now takes a person's token as well as their session, so the CLI refuses it as an operation that reads the person who calls it; the session-cookie-only case is pinned on updateMyUser. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmTvJjKuUM2VnUUGH9Y
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: a694ee2 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 |
The page test keeps its own rule for which operations the CLI calls: one that names no bearer scheme is a session's. A person's own read now names one, for a person's token, but takes no project secret, which the CLI holds, so the test reads x-zitadel-self as the docs' samples do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmTvJjKuUM2VnUUGH9Y
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. |
There was a problem hiding this comment.
🟡 Changes recommended
The breaking-change instructions omit additional Go client response-type replacements that can cause existing type switches and assertions to stop compiling.
1 open issue
What changed in this PR
Enables scoped personal tokens to read the caller’s identity and accessible projects through the API and MCP, while preserving project boundaries and rejecting project secrets on these reads.
Changes:
- Adds personal-token authentication to seven self-service reads.
- Updates MCP discovery, CLI refusals, documentation samples, and contract tests.
- Regenerates OpenAPI and Go bindings, including changed error response types.
| File | Description |
|---|---|
packages/go/api/oas_security_gen.go |
Adds self-read scope mappings. |
packages/go/api/oas_schemas_gen.go |
Updates generated error types. |
packages/go/api/oas_response_decoders_gen.go |
Decodes updated response types. |
packages/go/api/oas_json_gen.go |
Adds error serialization support. |
packages/go/api/oas_client_gen.go |
Adds OAuth authentication alternatives. |
packages/api/scripts/operations.ts |
Classifies personal authentication. |
docs/design/api/system-permission-catalog.md |
Documents self-read scope boundaries. |
docs/adrs/094-project-permission-model.md |
Records implemented personal reads. |
docs/adrs/092-mcp-server.md |
Updates tool eligibility and budgets. |
apps/docs/tests/pages.spec.ts |
Adjusts CLI sample expectations. |
apps/docs/lib/sdk-sample.ts |
Generates personal-token samples. |
apps/cli/tests/unit/lib/backend/services/operation.test.ts |
Tests personal-operation refusals. |
apps/cli/tests/integration/api.spec.ts |
Verifies CLI refusal envelopes. |
apps/cli/src/lib/backend/services/operation.ts |
Explains personal-operation refusals. |
apps/cli/skills/zitadel-cli/SKILL.md |
Documents CLI restrictions. |
apps/api/internal/mcp/handler.go |
Adds identity-discovery guidance. |
apps/api/internal/mcp/catalog.go |
Offers bearer tools without session-project arguments. |
apps/api/internal/mcp/catalog_test.go |
Tests tool schemas and budget. |
apps/api/internal/api/security.go |
Accepts personal tokens and skips secrets on self-reads. |
apps/api/internal/api/security_access_token_test.go |
Tests credential and scope boundaries. |
apps/api/internal/api/integration_test/user_test.go |
Updates error-type assertions. |
apps/api/internal/api/integration_test/mcp_test.go |
Verifies project-secret tool exclusions. |
apps/api/internal/api/integration_test/access_token_test.go |
Tests personal reads over HTTP and MCP. |
apps/api/internal/api/generated/oas_unimplemented_gen.go |
Refreshes generated operation comments. |
apps/api/internal/api/generated/oas_server_gen.go |
Refreshes handler interface comments. |
apps/api/internal/api/generated/oas_security_gen.go |
Adds server scope mappings. |
apps/api/internal/api/generated/oas_router_gen.go |
Allows Authorization headers on self-reads. |
apps/api/internal/api/generated/oas_response_encoders_gen.go |
Encodes updated error response types. |
apps/api/internal/api/generated/oas_json_gen.go |
Adds generated error serialization. |
apps/api/internal/api/generated/oas_handlers_gen.go |
Adds OAuth security checks. |
apps/api/internal/api/authz_ungated_contract_internal_test.go |
Tests self-service markers and project boundaries. |
apps/api/internal/api/authz_contract_internal_test.go |
Reads self-service markers in contract tests. |
apps/api/api/openapi/endpoints/users/me/teams/methods.yaml |
Adds scoped personal team reads. |
apps/api/api/openapi/endpoints/users/me/teams/listMyTeams-error-response.yaml |
Adds insufficient-scope errors. |
apps/api/api/openapi/endpoints/users/me/schema/methods.yaml |
Adds scoped personal schema reads. |
apps/api/api/openapi/endpoints/users/me/schema/getMyUserSchema-error-response.yaml |
Adds insufficient-scope errors. |
apps/api/api/openapi/endpoints/users/me/projects/methods.yaml |
Adds scoped personal project discovery. |
apps/api/api/openapi/endpoints/users/me/projects/listMyProjects-error-response.yaml |
Adds insufficient-scope errors. |
apps/api/api/openapi/endpoints/users/me/password/methods.yaml |
Adds scoped password-state reads. |
apps/api/api/openapi/endpoints/users/me/password/getMyPasswordState-error-response.yaml |
Adds insufficient-scope errors. |
apps/api/api/openapi/endpoints/users/me/passkeys/methods.yaml |
Adds scoped personal passkey reads. |
apps/api/api/openapi/endpoints/users/me/passkeys/listMyPasskeys-error-response.yaml |
Adds insufficient-scope errors. |
apps/api/api/openapi/endpoints/users/me/methods.yaml |
Adds personal user reads and self-service markers. |
apps/api/api/openapi/endpoints/users/me/identity_links/methods.yaml |
Adds scoped identity-link reads. |
apps/api/api/openapi/endpoints/users/me/identity_links/listMyIdentityLinks-error-response.yaml |
Adds insufficient-scope errors. |
apps/api/api/openapi/endpoints/users/me/getMyUser-error-response.yaml |
Adds insufficient-scope errors. |
apps/api/api/openapi/endpoints/sessions/me/methods.yaml |
Marks session operations as self-service. |
apps/api/api/openapi/endpoints/sessions/me/csrf/methods.yaml |
Marks CSRF retrieval as self-service. |
apps/api/api/openapi/bundled/openapi.json |
Refreshes the bundled contract. |
apps/api/api/openapi/AGENTS.md |
Documents self-service marker conventions. |
.changeset/api-person-token.md |
Adds release notes and Go migration guidance. |
Review effort: Balanced
| With `oauth.enabled`, the management API takes an access token the platform project's issuer signed for a person, as a bearer. The person acts with the grants their Console session has, on the operations a Console session may call, and the token's scopes are a ceiling on them: an operation that names a scope the token was not issued with answers `403` with the new error code `auth.scope_insufficient`, which those operations now list. The token ends when the person's session does. The platform project's issuer signs such a token for an authorization request that names the API with `resource` (RFC 8707), by the API's URL or the MCP endpoint's, with the scopes of the API it asks for: a resource the issuer has no API for answers `invalid_target`, and a scope the API does not define `invalid_scope`. `project.read` on such a token covers the reads of the project that name `project.write`. Through `search` it finds only the types whose read scope it also carries, such as `user.read` for users, and is refused with `auth.scope_insufficient` on any other. The invitation operations name the grant scopes in place of `project.write`, since an invitation ends in a grant: `grant.create` to create one, `grant.read` to read and `grant.delete` to cancel, with `user.read` for `expand=inviter`, and a replace with `replaces_invitation_id` needs `grant.delete` as well, plus `grant.read` when it sends no `metadata`; a project secret is unaffected, as its `project.write` covers every scope. An `expand` that reads another resource needs that resource's scope on such a token: `user.read` for a grant's `principal`, an invitation's `inviter` and a schema's `in_use`, `schema.read` for a flow definition's `user_schema`. The MCP endpoint shows such a token the tools its scopes cover, takes a token issued for the endpoint itself, which the API takes on the endpoint's calls only, and serves its protected-resource metadata (RFC 9728) at `/.well-known/oauth-protected-resource/api/v1/mcp`, named in the challenge of a `401`. | ||
| With `oauth.enabled`, the management API takes an access token the platform project's issuer signed for a person, as a bearer. The person acts with the grants their Console session has, on the operations a Console session may call, and the token's scopes are a ceiling on them: an operation that names a scope the token was not issued with answers `403` with the new error code `auth.scope_insufficient`, which those operations now list. The token ends when the person's session does. The platform project's issuer signs such a token for an authorization request that names the API with `resource` (RFC 8707), by the API's URL or the MCP endpoint's, with the scopes of the API it asks for: a resource the issuer has no API for answers `invalid_target`, and a scope the API does not define `invalid_scope`. `project.read` on such a token covers the reads of the project that name `project.write`. Through `search` it finds only the types whose read scope it also carries, such as `user.read` for users, and is refused with `auth.scope_insufficient` on any other. The invitation operations name the grant scopes in place of `project.write`, since an invitation ends in a grant: `grant.create` to create one, `grant.read` to read and `grant.delete` to cancel, with `user.read` for `expand=inviter`, and a replace with `replaces_invitation_id` needs `grant.delete` as well, plus `grant.read` when it sends no `metadata`; a project secret is unaffected, as its `project.write` covers every scope. An `expand` that reads another resource needs that resource's scope on such a token: `user.read` for a grant's `principal`, an invitation's `inviter` and a schema's `in_use`, `schema.read` for a flow definition's `user_schema`. A person's own reads take such a token too, each under the read scope of what it returns: `GET /users/me` and its `password`, `passkeys` and `identity_links` with `user.read`, `/users/me/projects` with `project.read`, `/users/me/teams` with `team.read` and `/users/me/schema` with `schema.read`; a project secret is answered on them as before. The MCP endpoint shows such a token the tools its scopes cover, takes a token issued for the endpoint itself, which the API takes on the endpoint's calls only, and serves its protected-resource metadata (RFC 9728) at `/.well-known/oauth-protected-resource/api/v1/mcp`, named in the challenge of a `401`. Its instructions tell an agent signed in as a person to start with `getMyUser`, then `listMyProjects`. | ||
|
|
||
| **Breaking:** in the Go client, the `403` of those seven `/users/me` reads is now an error with a `Code`, `sess.project_mismatch` or `auth.scope_insufficient` (`GetMyUserForbidden`, `ListMyProjectsForbidden` and so on, or `ErrorDetails`), in place of `SessProjectMismatch`. Switch on its `Code`. |
…o the policy work A remembered consent holds the person's answer for every scope offered, yes or no, so a client that asks for everything skips the step once the person answered, and is issued the scopes answered yes. A scope that is never remembered no longer forces the step: a skip does not issue it. A declined scope is asked for again with prompt=consent after the API's auth.scope_insufficient refusal. How long a consent lasts, and whether use renews it, is left open for the policy work; the me operations become two tools once #3559 lands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmUEzNb3SNs7Rj5USYf
main replaced the one budget on the whole tool list with three checks (#3555), so the raise this branch made to that budget goes. A person's own reads fit them: 86 tools on a plain URL, and 50 tools, 66,412 bytes, on the list a default consent yields. The tool-set tests expect the own reads in the users set, and ADR 092's measured figures say so. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
The Enable OAuth guide says which clients are asked once and which every time, and how a person lists and revokes a consent. ADR 082's amendment says the me operations take the session cookie until #3559 lets them take a person's token. The changeset covers the three code pieces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmUEzNb3SNs7Rj5USYf
main holds this branch's base as one squash commit (#3559). Its tree is the base's final head merged with the main before it, which this branch already holds, so the squash is recorded as merged and nothing changes. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
main gained a person's own reads (#3559), the client secret's rotation (#3561), the session type (#3551) and the CLI's client document (#3558). The personal access token migrations move behind the session type's (Postgres 64, Spanner 68, SQLite 51). A secret is refused on a person's own reads and on their personal access tokens alike, and the server's code is generated again from the merged spec. The tool-set tests expect the three token tools in the users set. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
main renumbered the migrations (#3551) and marks a person's own operations x-zitadel-self (#3559, #3560). listMyConsents takes the mark and a person's token with user.read; revokeMyConsent takes the mark and stays with the session cookie, as revokeMySession does. Generated files regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmUEzNb3SNs7Rj5USYf

Context
getMyUser, thenlistMyProjects"if they are in your list". This makes them so for a person's token. No overlap in code: feat(api): serve an Agent Skill on the MCP endpoint through the Skills extension #3550 editsbuildToolsand ADR 092 §10; this edits the instructions and ADR 092 §3, §4, §8./users/mereads to the app's project, which this keeps for a token).claude/my-sessions(listMySessions).Summary
The gap: an agent signed in to the MCP endpoint as a person could not ask who it acts for or which projects that person can work on. The
/users/mereads took only a session cookie, andsearchwas the workaround.The reads:
getMyUser,listMyProjects,listMyTeams,getMyUserSchema,listMyPasskeys,listMyIdentityLinksandgetMyPasswordStatetake a token issued for the person, each under the read scope of what it returns:getMyUser,listMyPasskeys,listMyIdentityLinks,getMyPasswordStateuser.readlistMyProjectsproject.readlistMyTeamsteam.readgetMyUserSchemaschema.readWithout the scope:
403 auth.scope_insufficient, naming it. A token is held to its project as a session is (sess.project_mismatch). All four scopes were already scopes a person's token can use, so the consent screen and the endpoint's metadata do not change.A project secret is no person. On these reads the security handler passes over a secret before it looks at it (
ErrSkipServerSecurity), so it is answered exactly as before:401, as a request without a credential.BearerCredential.Coverskeeps their tools from a secret, which could only refuse.The spec says it:
x-zitadel-self: truemarks the eleven self-service operations (/users/me,/sessions/me). A test holds the gate contract's self-service class and the server'spersonOwnOperationsto the marker. The CLI and the docs read it:@zitadel/api's operation list getsauth: "person", and the CLI, which holds a project secret, refuses those operations with a reason instead of sending its secret and reading the401as a bad secret.SKILL.mdsays so.ZITADEL_PROJECT_SECRET.MCP: a person's token with the scope is shown the tools. Their
project_id(thesession-project-idparameter, which holds a browser's cookie to the app's project) is no tool argument: a bearer belongs to one project, so it could only refuse, and an agent would read it as the project to act on. The instructions now say: "Signed in as a person, start with getMyUser, which says who they are, then listMyProjects, the projects they can act on, to learn where their work is."Tool list: 7 tools, 5,142 bytes.
listBudgetrises from 142,000 to 147,142, by that and no more. A project secret is still shown 79 tools, 141,563 bytes; a person's token with every scope 65 (88,512). All seven land in the list of a credential with every.readscope.Unchanged:
updateMyUser,getMySession,revokeMySession,getMySessionCsrfToken, the invitation and claim operations.listMyProjectsanswers what it answered before; each project's access is §10, step 6.Validation
Run by the session that wrote the change, in its cloud container:
go test ./internal/api/ ./internal/mcp/: newTestAPersonsTokenReadsWhatIsTheirOwn,TestASecretIsNoPersonOnAPersonsOwnRead,TestPersonOwnOperationsAreSelfService,TestNoToolTakesTheSessionsProject;TestSelfServiceHoldsTheSessionToItsProjectnow also holds a token to its project.go test -tags sqlite_integration ./internal/api/integration_test/ ./internal/api/integration_test/helpers/ ./internal/bootstrap/platform/: passes. NewTestAccessTokenReadsWhatIsThePersonsOwn(each read, over HTTP: with the scope the token answers what the cookie answers; without itauth.scope_insufficientnaming it; another projectsess.project_mismatch; a project secret answers what a request with no credential answers) and MCP subtests (a person's token is shown and calls the tools; a secret is shown none and is refused). Without the server change,getMyUserand all three MCP claims fail.go test ./...inapps/apipasses (with the Console built forcmd/server).turbo run lint --filter=@zitadel/serverpasses (check-generate, Redocly, Go lint).turbo run formatflagsinternal/flowengine/sso_test.go, which this does not touch: the container'sgofmtformats it differently than main's.pnpm run check-openapi-rules,turbo run test --filter=@zitadel/api-mockandturbo run typecheck --filter=@zitadel/docs(compiles every SDK sample) pass.npx vitest runinapps/clion this branch and on clean main, failures diffed. The same 98 terminal, spinner and local-runtime tests fail on both in that container. The one this change broke,tests/integration/api.spec.tspinninggetMyUser's old reason, is fixed in the second commit; the other two differences pass when run alone.full-prruns Postgres. The Spanner lane (spanner.yml, Spanner Omni) is not one of a pull request's checks: it runs weekly on main and on dispatch, and has not run on this branch.pages.spec.tskeeps its own copy of the rule for which operations the CLI calls and expected azitadel api getMyUsersample. It now readsx-zitadel-self, as the docs' samples do; verified against a built docs site and in CI.Checked when opening this draft:
node scripts/check-pr-title.mjs --title "…"passes, and I read the security handler's change. I did not rerun the suites.Release notes / changeset
.changeset/api-person-token.md(pending, unreleased), extended: a person's own reads take such a token; the MCP endpoint's instructions; Breaking for the Go client: the403of the seven reads is now an error with aCode(GetMyUserForbiddenand so on, orErrorDetails) in place ofSessProjectMismatch.Notes
x-zitadel-selfmarks a person's own operations in the spec. Alternative: a separate security scheme for a person's token, which would touch the generated server and every reader ofoauth2.401, as without a credential). Alternative: a403that says a secret is no person, a change for existing secret callers.listBudgetgrows by the seven tools' weight. That raise is dropped when feat(api): let an MCP client choose tool sets, and reads only, by its URL #3555 (tool sets by URL) lands, which replaces the budget; under its numbers the read list stays well below 80,000 bytes.https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Generated by Claude Code