Skip to content

feat(api)!: answer where a session or a request came from to the project's admins only - #3552

Merged
fforootd merged 8 commits into
mainfrom
claude/authz-session-gates
Dec 2, 2026
Merged

fforootd merged 8 commits into
mainfrom
claude/authz-session-gates

Conversation

@fforootd

@fforootd fforootd commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

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 session type to the catalog.

Summary

  • getSession asks session#reader and revokeSession asks session#revoker: the session's own user, an admin of its project (an owning team's member included) and operators.
  • querySessions asks admin on the project, because each session records the IP and user agent its user signed in from.
  • listEvents and getEvent answer a request's metadata.client.ip and metadata.client.user_agent only 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.
  • The gate contract (authz_contract_internal_test.go) names the session relations and why the list asks admin. The permission catalog drops session.read from project_viewer. ADR 094 marks step 2 built.

Validation

Run by the session that wrote the change, in its cloud container:

  • SQLite and Postgres 16: the full 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.
  • New tests, each failing without the change: TestSessionGates, TestEventsAnswerTheRequestClientToAdminsOnly.
  • go generate output (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: .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

  • Who notices today. Only a project secret reaches the session operations, and it administers its own project, so they change for nobody until a person's credential is admitted (ADR 094 step 5). The events change is what viewers and editors notice.
  • Callers checked by the writing session: the Console never shows these two fields and the CLI uses the project secret, so no Console, CLI, SDK or API mock caller needed a change.
  • Agents. A person's token held by a viewer or an editor no longer gets metadata.client.ip and user_agent through the MCP endpoint's listEvents and getEvent. 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.
  • Stack. Follows the session type'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.
  • Written in the session https://claude.ai/code/session_0137eGmTQoT7kemXw7jcdBJ3; the draft was opened by the coordinating session below.

https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U


Generated by Claude Code

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
@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 4:16pm UTC

Request Review

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: 990945a

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/cli Minor
@zitadel/testing Minor
@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
@zitadel/api 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-qwik-router Minor
@zitadel/sdk-react Minor
@zitadel/sdk-solid Minor
@zitadel/sdk-solid-start Minor
@zitadel/sdk-svelte Minor
@zitadel/sdk-sveltekit Minor
@zitadel/sdk-tanstack-start Minor
@zitadel/sdk-vue Minor
@zitadel/cloud Patch
@zitadel/client-sdk-contract Patch
@zitadel/server-sdk-contract Patch

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

@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-02T14:25:05.775368Z b831116 Draft marked ready
ℹ️ 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.

Base automatically changed from claude/authz-session-type to main December 2, 2026 15:37
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
@fforootd
fforootd enabled auto-merge December 2, 2026 15:48
Copilot AI balanced review requested due to automatic review settings December 2, 2026 15:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@fforootd
fforootd added this pull request to the merge queue Dec 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Dec 2, 2026
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
@fforootd
fforootd enabled auto-merge December 2, 2026 16:12
@fforootd
fforootd added this pull request to the merge queue Dec 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 2, 2026
@fforootd
fforootd added this pull request to the merge queue Dec 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 2, 2026
@fforootd
fforootd added this pull request to the merge queue Dec 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Dec 2, 2026
@fforootd
fforootd added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit eeda0ea Dec 2, 2026
17 checks passed
@fforootd
fforootd deleted the claude/authz-session-gates branch December 2, 2026 18:26
@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
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
fforootd pushed a commit that referenced this pull request Dec 2, 2026
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
fforootd pushed a commit that referenced this pull request Dec 2, 2026
…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

This branch was successfully deployed

1 active deployment
Preview — 990945ab 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.

3 participants