Skip to content

refactor(api): add the session type to the permission catalog - #3551

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

fforootd merged 2 commits into
mainfrom
claude/authz-session-type

Conversation

@fforootd

@fforootd fforootd commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Context

ADR 094 (the project permission model) is merged as a document and nothing of it was built. This is the first half of step 2 of its sequence (§12): the session type in the permission catalog (§2). The gates that ask it follow in the pull request stacked on this one. ADR 094's rule for the sequence is that each step leaves the system no less safe than the step before, on its own.

Summary

  • Migrations in all three dialects add session.project, session.user, session.reader and session.revoker. Reader and revoker close from the session's own user and from admin on its project. A session's project and user are facts of its row, never tuples.
  • domain.AuthzImpliedTuplesets names the relations no assignment holds. The compiler refuses any other relation that can hold none, and ValidateAssignment refuses every assignment that names a session or an implied tupleset (ADR 094's escalation path 7: nobody can grant themselves session#reader).
  • CheckSessionUser reads the implied session.user tuple by primary key. 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. A cross-dialect test holds the resolver 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.

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.
  • Spanner, on the Cloud Spanner emulator, run serially: everything passes except TestSearchEntryStatements_ConcurrentRevisionsOfOneKey, which fails the same way on main under the emulator. The new session, seed and migration suites pass. 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. This change has a Spanner migration, so dispatch that lane before trusting it there.
  • New tests, each failing without the change: TestCompilerAcceptsTheImpliedTuplesets, TestCompilerRefusesAnUnknownImpliedTupleset, TestOracle_Session, TestCheckPath_Session, TestValidateAssignment_SessionsAreNeverAssigned, TestAuthzCheckSessionUser, TestAuthzSessionAssignmentsAreRefused, TestAuthzResolver_SessionOracleAgreement.

Checked when opening this draft: node scripts/check-pr-title.mjs --title "…" passes, and the branch is one commit on current main.

Release notes / changeset

  • No changeset required — no shipped behavior changed: no gate asks a session relation until the next pull request.

Notes

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
@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 3:34pm UTC

Request Review

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ No Changeset found

Latest commit: 47e5d22

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a 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:18:58.215735Z eea6eaf 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.

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.

🔵 Needs a closer look

The Spanner catalog migration and resolver path have only emulator validation, while the explicitly required Spanner Omni workflow still needs to be run and its results inspected.

No open issues 🎉

1 file not reviewed
  • apps/api/internal/service/mocks/service.mock.go: Generated file
What changed in this PR

Adds the session permission-catalog foundation for ADR 094, preparing authorization checks for session owners and project admins. No API gate uses the new relations yet.

Changes:

  • Seeds session relations across PostgreSQL, SQLite and Spanner.
  • Adds session-owner resolution and rejects assignments to sessions or implied relations.
  • Extends compiler, resolver and cross-dialect tests.
File Description
apps/​api/​internal/​storage/​stmttest/​authz_session_test.go Tests session checks and oracle agreement across dialects.
apps/​api/​internal/​storage/​stmttest/​authz_platform_operator_test.go Adds sessions to the expected catalog model.
apps/​api/​internal/​storage/​dialect/​sqlite/​migration/​sql/​000050_authz_session.sql Seeds SQLite session relations.
apps/​api/​internal/​storage/​dialect/​sqlite/​authz_resolver.go Implements SQLite session-owner checks.
apps/​api/​internal/​storage/​dialect/​spanner/​migration/​sql/​000067_authz_session.sql Seeds Spanner session relations.
apps/​api/​internal/​storage/​dialect/​spanner/​authz_resolver.go Implements Spanner session-owner checks.
apps/​api/​internal/​storage/​dialect/​spanner/​authz_catalog_seed_test.go Updates catalog seed expectations.
apps/​api/​internal/​storage/​dialect/​postgres/​migration/​sql/​000063_authz_session.sql Seeds PostgreSQL session relations.
apps/​api/​internal/​storage/​dialect/​postgres/​authz_resolver.go Implements PostgreSQL session-owner checks.
apps/​api/​internal/​storage/​dialect/​postgres/​authz_catalog_seed_test.go Updates catalog seed expectations.
apps/​api/​internal/​storage/​dialect/​authz/​validate_assignment.go Rejects session and implied-relation assignments.
apps/​api/​internal/​storage/​dialect/​authz/​validate_assignment_test.go Tests assignment rejection.
apps/​api/​internal/​storage/​dialect/​authz/​session_user.go Builds shared session-owner SQL.
apps/​api/​internal/​storage/​AGENTS.md Documents assignment restrictions.
apps/​api/​internal/​service/​statement.go Adds the session-owner statement interface.
apps/​api/​internal/​service/​mocks/​service.mock.go Adds generated statement mocks.
apps/​api/​internal/​domain/​authz.go Defines session relations and check parameters.
apps/​api/​internal/​authz/​resolver/​session.go Resolves session-owner and project-admin access.
apps/​api/​internal/​authz/​resolver/​session_test.go Tests session resolution and restrictions.
apps/​api/​internal/​authz/​resolver/​session_oracle_test.go Tests expected session permissions.
apps/​api/​internal/​authz/​resolver/​resolver.go Routes session checks and rejects relation-based listing.
apps/​api/​internal/​authz/​resolver/​platform_operator_oracle_test.go Extends the oracle catalog model.
apps/​api/​internal/​authz/​resolver/​oracle.go Models session rows and permission checks.
apps/​api/​internal/​authz/​resolver/​decision.go Adds the session-owner authorization path.
apps/​api/​internal/​authz/​profile/​diagnostic.go Defines the unknown-implied-relation diagnostic.
apps/​api/​internal/​authz/​compiler/​implied.go Detects unsupported implied relations.
apps/​api/​internal/​authz/​compiler/​implied_test.go Tests accepted and rejected implied relations.
apps/​api/​internal/​authz/​compiler/​compiler.go Runs implied-relation validation.
apps/​api/​internal/​api/​authz_internal_test.go Extends the authorization test stub.

Review effort: Balanced

@fforootd
fforootd added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit af0e233 Dec 2, 2026
17 checks passed
@fforootd
fforootd deleted the claude/authz-session-type branch December 2, 2026 15:37
@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 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
fforootd pushed a commit that referenced this pull request Dec 2, 2026
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 pushed a commit that referenced this pull request Dec 2, 2026
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
fforootd pushed a commit that referenced this pull request Dec 2, 2026
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

This branch was successfully deployed

1 active deployment
Preview — 47e5d229 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