Repository navigation
feat(api)!: answer where a session or a request came from to the project's admins only - #3552
Conversation
ADR 094 §2, step 2 of its sequence: the catalog's first type below a project. A session's project and user are facts of its row, never tuples: - migrations in all three dialects add session.project, session.user, session.reader and session.revoker, with reader and revoker closing from the session's user and from admin on its project; - domain.AuthzImpliedTuplesets names the relations no assignment holds, the compiler refuses any other relation that can hold none, and ValidateAssignment refuses every assignment naming a session or an implied tupleset; - CheckSessionUser reads the implied session.user tuple by primary key, and the resolver answers a session relation as the session's own user first, then as admin on its project through the full project Check; - the oracle mirrors it, and a cross-dialect test holds the resolver and its foothold to the oracle for the session's user, another user, an admin, an owning team's member, an editor, a viewer, an operator, the project secret and a stranger. No gate asks a session relation yet; the next commit moves them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmTQoT7kemXw7jcdBJ3
ADR 094 §3, the gates of step 2 of its sequence: - getSession asks session#reader and revokeSession session#revoker: the session's own user, an admin of its project (an owning team's member included) and operators. A by-id gate of a resource with relations of its own (resourceAccess.object) asks that relation of the resource. - querySessions asks admin on the project: each session records the IP and user agent its user signed in from. - listEvents and getEvent answer a request's metadata.client.ip and user_agent only to an admin of the project, the events half of the ADR's escalation path 6; the admin question runs after the gate allowed, through the gate's resolver. The gate contract names the session relations and the reason the list asks admin; the permission catalog drops session.read from project_viewer; the ADR marks step 2 built. Only a project secret reaches the session operations today, and it administers its own project, so nothing changes for them until a person's credential is admitted; the events change is what viewers notice, and the changeset says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmTQoT7kemXw7jcdBJ3
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 990945a 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 |
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 holds this branch's base as one squash commit (#3551). 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
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the session authorization changes and admin-only event metadata restrictions.
No open issues 🎉
1 file not reviewed
packages/go/api/oas_client_gen.go: Generated file
What changed in this PR
Implements ADR 094’s session authorization gates and restricts request IP addresses and user agents in events to project admins.
Changes:
- Uses session reader/revoker relations and requires project admin access to list sessions.
- Redacts sensitive request metadata from events returned to non-admins.
- Adds authorization tests and updates API documentation, generated comments, and release notes.
| File | Description |
|---|---|
packages/go/api/oas_schemas_gen.go |
Updates generated metadata comments. |
packages/go/api/oas_client_gen.go |
Updates generated session operation comments. |
docs/design/api/system-permission-catalog.md |
Documents session relations and event visibility. |
docs/adrs/094-project-permission-model.md |
Marks session gates and event restrictions built. |
apps/api/internal/api/session.go |
Requires admin access for session lists. |
apps/api/internal/api/session_gate_internal_test.go |
Tests session ownership and admin gates. |
apps/api/internal/api/generated/oas_unimplemented_gen.go |
Refreshes generated session comments. |
apps/api/internal/api/generated/oas_server_gen.go |
Refreshes generated interface comments. |
apps/api/internal/api/generated/oas_schemas_gen.go |
Documents restricted metadata fields. |
apps/api/internal/api/generated/oas_handlers_gen.go |
Refreshes generated handler comments. |
apps/api/internal/api/event.go |
Checks admin access and redacts request metadata. |
apps/api/internal/api/event_client_internal_test.go |
Tests metadata visibility and preservation. |
apps/api/internal/api/authz.go |
Adds admin reads and resource-specific relations. |
apps/api/internal/api/authz_later_checks_internal_test.go |
Documents coverage for event visibility checks. |
apps/api/internal/api/authz_contract_internal_test.go |
Updates session authorization contract assertions. |
apps/api/api/openapi/endpoints/sessions/query/methods.yaml |
Documents admin-only session listing. |
apps/api/api/openapi/endpoints/sessions/by_id/methods.yaml |
Documents session reader and revoker access. |
apps/api/api/openapi/components/schemas/event-metadata.yaml |
Documents admin-only IP and user-agent fields. |
apps/api/api/openapi/bundled/openapi.json |
Refreshes bundled API descriptions. |
.changeset/session-reads-admin-only.md |
Announces authorization changes and breaking event restrictions. |
Review effort: Balanced
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 holds this branch's base, the session gates, as one squash commit (#3552). 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 session gates (#3552). Nothing here conflicts; the branch is level with main so that its checks run on what will land. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
…onsent Brings in main at eaced99 (#3552, #3562, #3564). The CLI's api-coverage test keeps only the two consent operations as not called: the personal access token commands now call theirs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmUEzNb3SNs7Rj5USYf
Context
Second half of step 2 of ADR 094's sequence (§3): the gates that ask the session relations, and the events half of the ADR's escalation path 6 (a viewer reads every session's and every request's IP and user agent). Stacked on the pull request that adds the
sessiontype to the catalog.Summary
getSessionaskssession#readerandrevokeSessionaskssession#revoker: the session's own user, an admin of its project (an owning team's member included) and operators.querySessionsasksadminon the project, because each session records the IP and user agent its user signed in from.listEventsandgetEventanswer a request'smetadata.client.ipandmetadata.client.user_agentonly to an admin of the project. The admin question runs after the gate allowed, through the gate's resolver: one more check per allowed read.authz_contract_internal_test.go) names the session relations and why the list asksadmin. The permission catalog dropssession.readfromproject_viewer. ADR 094 marks step 2 built.Validation
Run by the session that wrote the change, in its cloud container:
internal/api/integration_test,stmttest, dialect and migration suites pass. On the Cloud Spanner emulator, run serially, everything passes except one test that fails the same way on main under the emulator. 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.TestSessionGates,TestEventsAnswerTheRequestClientToAdminsOnly.go generateoutput (bundled spec, server stubs, Go client) regenerated; the OpenAPI lint reports 0 errors.Checked when opening this draft:
node scripts/check-pr-title.mjs --title "…"passes.Release notes / changeset
.changeset/session-reads-admin-only.md(@zitadel/server, minor, with a Breaking note). A viewer or an editor of a project no longer reads where a request came from in its events; a project secret is unaffected.Notes
metadata.client.ipanduser_agentthrough the MCP endpoint'slistEventsandgetEvent. The skill in feat(api): serve an Agent Skill on the MCP endpoint through the Skills extension #3550 mentions those fields and will be worded for admins.sessiontype's pull request (zitadel/nextgen#3551), which is merged; step 3 (the platform issuer's first-party clients) is its own pull request against main; step 4 follows.https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Generated by Claude Code