Repository navigation
[M2.3b2] Enforce tenant row isolation and concurrent owner protection - #78
Merged
Merged
Conversation
5 tasks done
samuelmbabhazi
force-pushed
the
feat/m2.3b1-tenant-schema
branch
from
November 5, 2026 12:44
8eecc56 to
5bac68c
Compare
samuelmbabhazi
changed the base branch from
feat/m2.3b1-tenant-schema
to
main
November 5, 2026 12:44
samuelmbabhazi
force-pushed
the
feat/m2.3b2-tenant-isolation
branch
from
November 5, 2026 12:44
9106db3 to
dae86da
Compare
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
## Task M2.3b3, stacked on #78 (`feat/m2.3b2-tenant-isolation`). ## What changed and why Require every fleet node and enrollment token to reference an existing organization. Organization deletion is restricted while either kind of record remains, so it cannot silently cascade into servers, certificates or enrollment history. Abort migration on legacy orphan references with an opaque diagnostic; do not invent owners, move servers or delete records. Seed a real organization and verified owner in the existing enrollment acceptance fixture. ## Validation - Six PostgreSQL tests cover rejected orphan inserts/updates, deletion restrictions and failed migration preservation for both fleet tables. - Real CA-backed enrollment still passes. All 104 PostgreSQL integration tests pass with the new migration. - Prisma format/generation, API lint/typechecks and 103 API unit tests pass. Go tests and buf lint passed earlier in this session; their sources are unchanged. ## Security considerations This adds referential integrity only. Runtime fleet authorization/transactions belong to the separate M1.2 stack; tenant context and restricted database-role enforcement continue in M2.3c. No endpoint, automatic cleanup, new application mutation, dependency, secret or shell invocation is added. Existing installations with orphan records require explicit reconciliation with their verified owners before upgrading. ## Checklist - [x] M2.3b3 acceptance and orphan-migration cases covered - [x] PostgreSQL regression suite and API checks pass - [x] SPEC and PLAN updated - [x] No new application mutation requiring an audit event - [x] No implicit server deletion or arbitrary ownership assignment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task
M2.3b2, stacked on #77 (
feat/m2.3b1-tenant-schema).What changed and why
Force PostgreSQL row security on organizations, memberships, projects, environments and role bindings. A transaction-local organization context scopes reads and writes; missing context denies access. Deferred constraint triggers require every surviving organization to retain an owner and permit atomic ownership transfers. A serialized organization write prevents concurrent owner removals, including stale snapshots at REPEATABLE READ. Checks retain their stored tenant when a caller changes context before commit. Migration refuses pre-existing ownerless organizations.
Validation
Security considerations
The trigger runs with invoker privileges, a fixed search path and qualified table names. No security-definer bypass, new dependency, secret or application shell invocation is added. This slice exposes no tenant endpoint or application mutation. M2.3c must enforce a restricted runtime database role and transaction context before tenant routes are enabled; superusers and BYPASSRLS roles still bypass PostgreSQL RLS. Fleet foreign keys remain tracked in M2.3b3.
Checklist