Repository navigation
[M2.3c1] Scope tenant transactions and reject unsafe database roles - #80
Merged
Merged
Conversation
5 tasks done
samuelmbabhazi
force-pushed
the
feat/m2.3b3-fleet-organization-links
branch
from
November 5, 2026 12:45
8df85ae to
d52e4d3
Compare
samuelmbabhazi
changed the base branch from
feat/m2.3b3-fleet-organization-links
to
main
November 5, 2026 12:45
samuelmbabhazi
force-pushed
the
feat/m2.3c1-tenant-transactions
branch
from
November 5, 2026 12:45
4cab3ff to
d90d39d
Compare
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
## Task M2.3c2a, stacked on #80 (`feat/m2.3c1-tenant-transactions`). ## What changed and why Separate the administrative migration URL from the API runtime URL. Add explicit restricted-role provisioning, a loopback-only development setup command and deployment instructions. Runtime grants exclude migration tracking, public-schema creation and tenant DDL; audit events allow SELECT/INSERT only. Existing credentials are never rewritten. Create the queue schema during migration and disable pg-boss schema creation at runtime. Provisioning transfers only existing queue objects inside `shipkeep_jobs`, preserving queued work while leaving tenant tables under administrative ownership. A disposable restricted-login app fixture enables future tenant acceptance tests. ## Validation - All 128 PostgreSQL integration tests pass, including four new full-app restricted-login tests: account registration/verification with audit, tenant transactions, forbidden audit/DDL operations, queue preservation on repeated provisioning and unsafe-role rejection. - The development setup command was exercised against a disposable PostgreSQL instance: initial creation, rerun, real login and unsafe-configuration rejection passed. - API lint, typechecks, 103 unit tests and build pass; tooling ESLint passes. Workspace web/domain checks, Go tests and buf lint passed earlier in this session; their sources are unchanged. ## Security considerations The runtime group is NOLOGIN and has no elevated role attributes or memberships. The SQL provisioning script operates on a dedicated Shipkeep database and must run transactionally as its administrator. It never globally reassigns administrative objects. Development setup accepts only matching loopback databases and a separate `shipkeep_app` login, refuses production mode, and prints no credentials or driver diagnostics. No application shell invocation or new runtime domain command is introduced. M2.4 retains the remaining audit guarantees/export/UI scope. Existing development `.env` files must explicitly adopt the two URLs; this PR does not rewrite them. Production operators must apply migrations, then runtime grants, and configure a private login before exposing tenant routes. ## Checklist - [x] M2.3c2a acceptance covered with a real restricted login - [x] PostgreSQL regression suite and API/tooling checks pass - [x] Development setup tested on a disposable database - [x] SPEC, PLAN, README and deployment instructions updated - [x] No automatic password overwrite, secret output or application shell call
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.3c1, stacked on #79 (
feat/m2.3b3-fleet-organization-links).What changed and why
Add
PrismaUnitOfWork.runTenantso tenant repositories and audit writes use one transaction-local organization context. Same-tenant nested commands join their caller; changed-tenant or overlapping sibling scopes are rejected before they can race on connection settings. Context is cleared before returning to an outer identity transaction and on transaction completion.Before each tenant operation, validate the login/effective database roles, role memberships, table RLS flags and row-security setting. Refuse privileged logins, ownership, public-schema DDL and tenant-table TRUNCATE/TRIGGER access, including privileges reachable through non-inherited roles. Validate canonical UUIDv7 tenant ids and replace driver errors with an opaque storage-unavailable error.
Validation
Security considerations
Setting a tenant context is not an authorization grant; live membership/resource policy checks remain required in the application adapters. This foundation does not expose tenant HTTP routes. Runtime-role provisioning and repositories continue in M2.3c2. Existing unscoped identity/audit unit-of-work behavior is retained and covered by the full integration suite. No dependency, secret, application shell call or new unaudited command is added.
Checklist