Repository navigation
[M2.3c4b] Manage memberships and preserve the final owner - #90
Merged
Merged
Conversation
5 tasks done
samuelmbabhazi
force-pushed
the
feat/m2.3c4a-privilege-change-locks
branch
from
November 5, 2026 14:48
9df2046 to
1c34e55
Compare
samuelmbabhazi
changed the base branch from
feat/m2.3c4a-privilege-change-locks
to
main
November 5, 2026 14:48
samuelmbabhazi
force-pushed
the
feat/m2.3c4b-membership-commands
branch
from
November 5, 2026 14:50
e536f50 to
407dfb3
Compare
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
## Task M2.3c4c1, stacked on #90. Review in order; no automatic merge. ## What changed and why Add audited project/environment role assignment and removal with fresh password/MFA proof and ordered actor/subject locks. Assignment resolves only an exact existing organization member by email after scope authorization; it cannot add organization membership or grant ownership. New/changed bindings require an active verified member. Removal also works for disabled or subsequently promoted accounts. Live scope checks honor explicit environment downgrades: a project administrator downgraded in an environment cannot remove that restriction themselves. Removing an override can restore inherited rights, so removal invalidates credentials just like assignment. Self-changes return a rotated session; unchanged/absent grants preserve credential versions and audit proof confirmation. ## How it was tested - Seven real restricted-PostgreSQL acceptance tests pass: assignment/update/removal, idempotence, all administration scopes, self-demotion, explicit overrides, wrong ancestry/recipients/roles, duplicate concurrency, directory races and audit rollback. - Application coverage: 98% statements, 97% branches, 100% functions and lines. - API lint, typechecks, 103 unit tests and production build pass. - Parent PR #90 passed the full integration, browser, generated-contract, Go and enabled security checks. CI runs the expanded suite for this PR. ## Security considerations Scope administrators do not receive a global account directory. Resource ancestry and membership are rechecked under account/organization locks before writing. Binding updates cannot change their tenant, parent resource or membership. Audits and credential invalidation commit together. No new dependency, shell invocation or credential exposure path. CodeQL remains skipped by repository configuration. ## Checklist - [x] M2.3c4c1 acceptance met; PLAN/SPEC updated - [x] Local static checks, tests and build pass - [x] Scope escalation, concurrency and rollback acceptance covered - [x] Every grant mutation emits an atomic audit event - [x] No secrets or generated artifacts edited manually
5 tasks done
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
… enrollment errors (#109) ## Task Review follow-ups for #90, #91 and #102, plus two rule-audit items. Refs #22 ## What changed **No directory oracle (#90, #91)** - `AccountMutationAuthority.confirmPassword()` checks the caller's password without locks. - `MembershipCommands.add` and `BindingCommands.assign` call it before answering `resource_not_found` for an unknown address. An unknown account and a wrong password now give the same 401, so these commands cannot list the instance's verified accounts or an organization's members. The success path still pays one Argon2id verification. **Environment overrides (#91)** - An administrator of a single environment can no longer create or remove an environment override for a member who administers the whole project. Before, the project admin could not undo such a restriction. - Project admins and organization owners/admins are unaffected. **Explicit response fields (#102)** - `resourceDto` spread whole store rows into responses. It is replaced by `organizationDto`, `projectDto`, `environmentDto`, `memberViewDto` and `bindingViewDto`, which list every field. A future column cannot reach session or bearer clients without a DTO change. - The HTTP test asserts the exact key sets for project and environment details. **Rule audit items** - The agent's enrollment error keeps its gRPC code (wrapped with `%w`) and still drops the remote text. Its test fails without the fix (`Unknown`). - An `eslint-disable` gains its justification. - SPEC: directory lookup ordering, the environment-override rule (section 7), and bearer status codes (401 for bad tokens or token-less routes, 403 for scope gaps checked before any lookup, so nothing leaks). ## How it was tested - Local gate on the branch: lint, typecheck, unit tests and build for all projects; go vet, go test and golangci-lint; no generated-code drift; Semgrep and Prettier. - New integration tests: same 401 for unknown and existing accounts on membership add and binding assign; environment admin refused on a project admin, owner allowed. - CI is unavailable (account spending limit), so integration tests did not run. ## Checklist - [x] Local gate passes - [x] Tests added - [x] No new shell invocation and no new secret exposure path - [x] Audit events unchanged (refused commands write nothing) - [x] SPEC updated
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.3c4b, stacked on #89. Review in order; no automatic merge.
What changed and why
Add reauthenticated organization membership commands for existing verified accounts, explicit role changes and removal. Actor/subject account locks precede the organization lock; live authorization and owner count are then rechecked before writing. Administrators manage non-owners, owners manage ownership, and simultaneous departures cannot remove the final owner.
Membership changes and audits share the credential-invalidation transaction. Self-demotion returns a rotated session. Same-role requests preserve credential versions; removal cascades resource bindings. Directory candidates are rechecked after locking to reject changed email/active state. Unknown or unverified accounts are not invited by this slice.
Also add pure, closed organization/resource-role parsers with canonical-value tests. HTTP and administration screens follow in M2.3d/f.
How it was tested
Security considerations
Only authorized organization administrators can resolve a membership candidate. Commands never receive password hashes and cannot move a membership across tenants. Role changes recheck current account versions under ordered locks; the database's deferred owner guard remains a second defense. Failed audits roll back membership and credential state together. No new dependency, shell invocation or secret exposure. CodeQL remains skipped by repository configuration; enabled security checks run in CI.
Checklist