Repository navigation
feat(api): list a person's own sessions, with where each began - #3560
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
GET /users/me/sessions (listMySessions) lists the signed-in person's own sessions in the project they signed in to, newest first, each with its state and the IP address and user agent it began with, never its token (ADR 094 §6, the rest of step 1 of §12). It needs none of §2's session type: its filter is the session's user_id, so no Check is asked and another user's session is never in it. - It takes the person's session cookie, or a token issued for them with session.read, held to its project with project_id as the other /users/me reads. A project secret is no person: 401, and no tool. - session.read becomes a scope a person's token can use, so the consent screen words it in en, de and it, and the MCP endpoint's metadata lists it. - One more tool, 854 bytes: listBudget rises to 147,996. 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
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: 2f7ef36 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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmTvJjKuUM2VnUUGH9Y
…tests The CLI holds a project secret and does not call a person's own sessions, so the coverage test says why, beside the other /users/me reads. In the spec's order /users/me/sessions now comes before /sessions, which moves the first row api ls sessions prints. 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. |
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 base took main's three checks on the tool list in place of the one budget, so the raise this branch made goes. listMySessions fits them: 87 tools on a plain URL, and 51 tools, 67,266 bytes, on the list a default consent yields. The tool-set tests expect it in the users set, and ADR 092's measured figures count it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
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 the client secret's rotation (#3561) and the session type (#3551). The generated router conflicted, so the server's code is generated again from the merged spec. ADR 092's measured figures count rotation's tool: 88 on a plain URL. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the self-service session-listing change.
No open issues 🎉
What changed in this PR
Adds listMySessions to Zitadel’s self-service API, extending the personal-token reads introduced in #3559 and completing ADR 094’s first implementation step.
Changes:
- Lists the caller’s own sessions within their sign-in project, including origin details but no session tokens.
- Adds the OpenAPI contract, generated Go support, and authentication and MCP coverage.
- Updates consent translations, CLI expectations, documentation, and release notes.
| File | Description |
|---|---|
packages/go/api/oas_validators_gen.go |
Generates response-wrapper validation. |
packages/go/api/oas_security_gen.go |
Registers supported credentials and scope. |
packages/go/api/oas_schemas_gen.go |
Generates response and error types. |
packages/go/api/oas_response_decoders_gen.go |
Decodes endpoint responses. |
packages/go/api/oas_parameters_gen.go |
Adds pagination and project parameters. |
packages/go/api/oas_operations_gen.go |
Adds the operation constant. |
packages/go/api/oas_json_gen.go |
Generates error JSON serialization. |
packages/go/api/oas_interfaces_gen.go |
Adds the response interface. |
packages/go/api/oas_client_gen.go |
Adds the Go client method. |
docs/design/api/system-permission-catalog.md |
Documents self-access and its scope. |
docs/adrs/094-project-permission-model.md |
Records completion of self-service session listing. |
docs/adrs/092-mcp-server.md |
Updates tool documentation and counts. |
apps/console/src/features/sign-in/consent-texts.ts |
Adds session consent translations. |
apps/cli/tests/unit/cli/commands/api/ls.test.ts |
Updates operation-order expectations. |
apps/cli/tests/unit/cli/commands/api-coverage.test.ts |
Records the person-only operation exclusion. |
apps/api/internal/mcp/sets_test.go |
Includes session listing in user tool sets. |
apps/api/internal/api/session.go |
Implements project- and user-filtered listing. |
apps/api/internal/api/security.go |
Registers self-service authentication handling. |
apps/api/internal/api/security_access_token_test.go |
Checks the required token scope. |
apps/api/internal/api/integration_test/mcp_test.go |
Checks tool exclusion for project secrets. |
apps/api/internal/api/integration_test/access_token_test.go |
Tests authentication, ownership, and token omission. |
apps/api/internal/api/generated/oas_validators_gen.go |
Generates server response validation. |
apps/api/internal/api/generated/oas_unimplemented_gen.go |
Adds the fallback handler. |
apps/api/internal/api/generated/oas_server_gen.go |
Extends the server handler interface. |
apps/api/internal/api/generated/oas_security_gen.go |
Generates endpoint security mappings. |
apps/api/internal/api/generated/oas_schemas_gen.go |
Generates server response and error types. |
apps/api/internal/api/generated/oas_router_gen.go |
Routes the new endpoint. |
apps/api/internal/api/generated/oas_response_encoders_gen.go |
Encodes responses and cache headers. |
apps/api/internal/api/generated/oas_parameters_gen.go |
Decodes and validates request parameters. |
apps/api/internal/api/generated/oas_operations_gen.go |
Adds the server operation constant. |
apps/api/internal/api/generated/oas_json_gen.go |
Generates server error serialization. |
apps/api/internal/api/generated/oas_interfaces_gen.go |
Adds the server response interface. |
apps/api/internal/api/generated/oas_handlers_gen.go |
Generates request handling. |
apps/api/internal/api/authz_ungated_contract_internal_test.go |
Classifies the operation as self-service. |
apps/api/api/openapi/openapi-spec.yaml |
Registers the endpoint specification. |
apps/api/api/openapi/endpoints/users/me/sessions/methods.yaml |
Defines authentication, pagination, and responses. |
apps/api/api/openapi/endpoints/users/me/sessions/listMySessions-error-response.yaml |
Generates the endpoint error catalog. |
apps/api/api/openapi/bundled/openapi.json |
Includes the new contract in the bundle. |
.changeset/api-person-token.md |
Adds session listing to release notes. |
Review effort: Balanced
main gained a person's own sessions (#3560). The server's code is generated again from the merged spec, the tool-set tests expect both changes' tools in the users set, and ADR 092's measured figures count the three token tools: 91 on a plain URL, and 52 tools, 68,271 bytes, on the list a default consent yields. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
main gained a person's own sessions (#3560), which the permission catalog lists beside this branch's session relations: both stay on the session.read row. 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
listMySessions, the rest of step 1 of §12. §2 says its filter is the session'suser_id, not a resolver predicate, so it needs none of §2's session type (step 2, refactor(api): add the session type to the permission catalog #3551).listMySessionsorGET /users/me/sessionscame up in a search of issues and pull requests.Summary
listMySessions(GET /users/me/sessions) lists the signed-in person's own sessions in the project they signed in to, newest first, each with itsstate, the IP address and user agent it began with, and never its token. The answer isquerySessions' shape (sessions,next_page_token), paged withlimitandpage_token.session.read; without the scope403 auth.scope_insufficient. It is held to the project it belongs to withproject_id, as the other/users/mereads. A project secret is no person:401, as a request without a credential, and no tool.user_idas its filter, so another user's session is never in it, whatever the person administers.querySessionsandgetSessionstay as they are until §3.session.readbecomes a scope a person's token can use, so the consent screen words it ("View sessions and where each began", in en, de and it, in a "Sessions" group) and the MCP endpoint's metadata lists it.listBudgetrises from 147,142 to 147,996, by that and no more. A person's token with every scope is shown 66 tools (89,366 bytes); with every.readscope, 49 (64,575), of which the eight/users/mereads are 5,996 bytes. A project secret is still shown 79.Validation
Run by the session that wrote the change, in its cloud container:
go test ./internal/api/ ./internal/mcp/passes, withlistMySessionsinTestAPersonsTokenReadsWhatIsTheirOwn, the self-service contract andTestPersonScopesHaveConsentTextsInTheConsole.go test -tags sqlite_integration ./internal/api/integration_test/ ./internal/api/integration_test/helpers/ ./internal/bootstrap/platform/passes. NewTestAccessTokenListsThePersonsOwnSessions(the person's sessions, the one the token was issued in and another, and not a stranger's in the same project; no token in the answer);/users/me/sessionsjoinsTestAccessTokenReadsWhatIsThePersonsOwn(token with and without the scope, the cookie, another project, a project secret) and the MCP subtests.turbo run generate --filter=@zitadel/serverand--filter=@zitadel/api;turbo run lint --filter=@zitadel/server(only thegofmtfinding in an untouched file);turbo run typecheck --filter=@zitadel/docs; the CLI'soperation.test.tsandapi.spec.tsrefusals.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.api-coverageandapi lstests, which enumerate the client's operations, were updated for the new operation.Checked when opening this draft:
node scripts/check-pr-title.mjs --title "…"passes. I did not rerun the suites.Release notes / changeset
.changeset/api-person-token.md(pending), extended withGET /users/me/sessions.Notes
session.readis a read scope, so the consent step starts with it ticked, as it does every read.apps/docs/content/docs/guides/investigate-with-events.mdxreads sign-ins with the CLI, which holds a project secret and cannot call this; ADR 094's documentation list names that guide, and it waits for the CLI's sign-in as a person.revokeSessionasksadminuntil §3'ssession#revoker(feat(api)!: answer where a session or a request came from to the project's admins only #3552).https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Generated by Claude Code