Repository navigation
[M2.3c4a] Serialize privilege changes and invalidate affected credentials - #89
Merged
Merged
Conversation
5 tasks done
samuelmbabhazi
force-pushed
the
feat/m2.3c3c2-resource-catalogs
branch
from
November 5, 2026 14:47
d89cbee to
9530152
Compare
samuelmbabhazi
changed the base branch from
feat/m2.3c3c2-resource-catalogs
to
main
November 5, 2026 14:47
samuelmbabhazi
force-pushed
the
feat/m2.3c4a-privilege-change-locks
branch
from
November 5, 2026 14:48
9df2046 to
1c34e55
Compare
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
## 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 - Seven real restricted-PostgreSQL acceptance tests pass, covering administrator/owner restrictions, last-owner races, duplicate additions, self-demotion, invalid/stale/inactive inputs, directory races, cascading grants and rollback for every command. - Application coverage: 97% statements, 94% branches, 100% functions and lines. - All 94 domain and 103 API unit tests pass, with API/domain lint, typechecks and production builds. - The preceding full 177-test integration suite passed; CI runs the expanded suite and browser checks. Web, Go and protobuf checks passed earlier in the stack. - One local Nx native-runner process crashed; rerunning with its native command runner disabled completed successfully. ## 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 - [x] M2.3c4b acceptance met; PLAN/SPEC updated - [x] TDD role policy and real PostgreSQL command acceptance pass - [x] Relevant lint, typechecks, unit tests and builds pass - [x] Every membership mutation emits an atomic audit event - [x] No secrets or generated artifacts edited manually
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.3c4a, stacked on #88. Review in order; no automatic merge.
What changed and why
Add an identity boundary for privilege changes that locks the actor and affected account in canonical UUID order before organization locks. Fresh password/configured MFA proof is required. Changed privileges invalidate the affected account's sessions and version-bound API tokens in the same transaction as the role/audit writes; self-changes return a rotated session. Another administrator's session remains valid.
No-ops preserve credentials but audit proof confirmation, since an MFA counter/recovery code may still be consumed. Proof explicitly expires when its callback ends, including inherited detached asynchronous work. The internal verified-account directory returns only account id/email/active state for authorized membership commands.
Membership and role-binding commands follow in M2.3c4b/c. Callers must enter this boundary before holding any account or organization lock and repeat resource authorization under its locks.
How it was tested
Security considerations
Callbacks never receive password hashes or MFA material. Role mutations, proof consumption, audit and security-version changes share one transaction. A failed identity audit restores the business write and credentials. No new dependency, shell invocation or credential logging path. CodeQL remains skipped by repository configuration; enabled security checks run in CI.
Checklist