Repository navigation
refactor(api): add the session type to the permission catalog - #3551
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
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.
🔵 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
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
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
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
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
sessiontype 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
session.project,session.user,session.readerandsession.revoker. Reader and revoker close from the session's own user and fromadminon its project. A session's project and user are facts of its row, never tuples.domain.AuthzImpliedTuplesetsnames the relations no assignment holds. The compiler refuses any other relation that can hold none, andValidateAssignmentrefuses every assignment that names a session or an implied tupleset (ADR 094's escalation path 7: nobody can grant themselvessession#reader).CheckSessionUserreads the impliedsession.usertuple by primary key. The resolver answers a session relation as the session's own user first, then asadminon its project through the full project check.Validation
Run by the session that wrote the change, in its cloud container:
internal/api/integration_test,stmttest, dialect and migration suites pass.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.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
Notes
000063, SQLite000050and Spanner000067are also used by the open webhooks drafts refactor(api): add storage for a project's webhooks #2987 and feat(api): deliver a project's events to its webhooks, signed #2991. Whoever merges second renumbers.platformorproject, or when it is any assignable relation ofsession. The alternative is an explicit marker per relation.system-permission-catalog.md(text conflicts only). No open pull request changes the resolver orauthz_contract_internal_test.go.https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Generated by Claude Code