Repository navigation
[M2.3c2b1] Discover organizations through account-scoped row policies - #82
Merged
Merged
Conversation
4 tasks done
samuelmbabhazi
force-pushed
the
feat/m2.3c2a-runtime-database-role
branch
from
November 5, 2026 12:46
840011a to
2fcc9a0
Compare
samuelmbabhazi
changed the base branch from
feat/m2.3c2a-runtime-database-role
to
main
November 5, 2026 12:46
samuelmbabhazi
force-pushed
the
feat/m2.3c2b1-organization-discovery
branch
from
November 5, 2026 12:46
48a2075 to
85f7cf6
Compare
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
## Task M2.3c2b2, stacked on #82 (`feat/m2.3c2b1-organization-discovery`). ## What changed and why Resolve current active/verified membership, organization/project ancestry, environment protection and role bindings before applying the tenant policy. Reject unknown capabilities, invalid identifiers and incomplete contexts before storage access. Ignore caller-supplied role/protection metadata, use a shared canonical UUIDv7 validator and return the same resource-not-found error for unavailable permissions and resources. All reads include organization filters inside the tenant unit of work. Grant lookup is bounded to the unique project grant and the relevant environment grant (or one environment grant for parent navigation). The read-side module is independent of identity commands, preparing live token authorization without a module dependency cycle. ## Validation - Seven restricted-login PostgreSQL tests cover foreign/sibling resource references, environment protection changes, explicit role downgrades, environment-only grants, account disabling, membership removal, malformed inputs and joining/rolling back the caller transaction. - All 143 PostgreSQL integration tests pass. The final bounded grant query also passes the targeted suite with 100% statement/branch/function coverage across the new authorization service and repository. - API/web/domain lint, types, tests and builds pass; final API lint/types pass after query bounding. Go tests and buf lint passed earlier in this session; their sources are unchanged. ## Security considerations No permission cache, HTTP endpoint, token-authority switch or unaudited mutation is introduced here. M2.3c3/c4 add audited commands and serialize role changes with identity locks; M2.3d wires session/bearer routes. Membership/account state and resource ancestry come only from current database rows. No dependency, secret or application shell invocation is added. ## Checklist - [x] M2.3c2b2 acceptance and cross-resource boundaries covered - [x] Restricted-login integration and application coverage checks pass - [x] SPEC and PLAN updated - [x] No new application mutation requiring an audit event
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.3c2b1, stacked on #81 (
feat/m2.3c2a-runtime-database-role).What changed and why
Allow an authenticated account to discover its own organizations before selecting a tenant. SELECT-only RLS policies expose only its memberships and organization metadata, and only while the account is active and verified. Project/environment contents, role bindings and tenant writes remain inaccessible in discovery mode.
Add
runAccountDiscoverywith a transaction-local account setting. Tenant and account scopes are mutually exclusive, preserve same-scope nesting and clear both settings on exit. A caller cannot switch account or scope within an active transaction context. The identity must come from authentication, never a caller-selected account parameter.Validation
Security considerations
No security-definer function or RLS bypass is added. Discovery does not expose other members, grant tenant write permissions or substitute for live application authorization. No tenant HTTP route is exposed by this slice; scoped repositories and authorization adapters follow. Account-status checks use existing identity columns. No dependency, application shell call, secret or new domain mutation is introduced.
Checklist