feat(accounts): UserStatus.Pending + workspace gating (task 1.1, ACC-01…04) #53

Merged
amiryahaya merged 1 commit from feat/1.1-user-status-gating into main 2026-11-04 18:38:57 +01:00
Owner

Phase 1 feature work begins. Task 1.1 adds the account-lifecycle gating that the org-request flow (tasks 1.2/1.3) builds on.

Behavior (SRS ACC-01…04)

  • UserStatus.Pending — org founders awaiting system-admin approval
  • Pending users: tenant-scoped file APIs → 403 org_approval_pending; account-level endpoints (me / org-requests / invitations / recovery / account / credentials / devices / auth) remain usable
  • Active users with no workspace: tenant-scoped APIs → 403 no_workspace; SuperAdmin exempt (ACC-03)
  • Personal auto-tenant creation removed (GetRootFolder kept only for SuperAdmin console convenience; RegisterVerify AdminDid bootstrap creates the SuperAdmin without a workspace — verified by test)
  • FileActivity fire-and-forget calls no longer bound to the request CancellationToken (audit events survive client timeouts)

Tests (TDD §2.1)

UserStatusGatingTests (7) + AdminDidRegistrationTests (1) written first — red at 6 failures, green after implementation. Two latent bugs found and fixed during green: FK-ordering in the SuperAdmin bootstrap tenant flow + the #44-class AsNoTracking mutation in GetRootFolder.

Verification

754/754 ×3 (Release); pre-push hook green incl. coverage gate (83.40% ≥ 80).

Closes #16 (task 1.1). Also closes #10 (0.2 PRF deferred to Phase 2 E2E per decision — rationale on the issue).

Phase 1 feature work begins. Task 1.1 adds the account-lifecycle gating that the org-request flow (tasks 1.2/1.3) builds on. ## Behavior (SRS ACC-01…04) - `UserStatus.Pending` — org founders awaiting system-admin approval - Pending users: tenant-scoped file APIs → **403 org_approval_pending**; account-level endpoints (me / org-requests / invitations / recovery / account / credentials / devices / auth) remain usable - Active users with no workspace: tenant-scoped APIs → **403 no_workspace**; SuperAdmin exempt (ACC-03) - **Personal auto-tenant creation removed** (GetRootFolder kept only for SuperAdmin console convenience; RegisterVerify AdminDid bootstrap creates the SuperAdmin without a workspace — verified by test) - FileActivity fire-and-forget calls no longer bound to the request CancellationToken (audit events survive client timeouts) ## Tests (TDD §2.1) `UserStatusGatingTests` (7) + `AdminDidRegistrationTests` (1) written first — red at 6 failures, green after implementation. Two latent bugs found and fixed during green: FK-ordering in the SuperAdmin bootstrap tenant flow + the #44-class AsNoTracking mutation in GetRootFolder. ## Verification 754/754 ×3 (Release); pre-push hook green incl. coverage gate (**83.40%** ≥ 80). Closes #16 (task 1.1). Also closes #10 (0.2 PRF deferred to Phase 2 E2E per decision — rationale on the issue).
feat(accounts): UserStatus.Pending + workspace gating for tenant-scoped APIs (task 1.1, closes #16)
All checks were successful
API CI / build-and-test (pull_request) Successful in 34m39s
010a3b13cf
SRS ACC-01…04 — account lifecycle states gate the file surface:
- UserStatus gains Pending (appended; string-mapped column, no migration)
- SsdidAuthMiddleware: Pending users → 403 org_approval_pending on
  tenant-scoped APIs (folders/files/shares/activity) with an account-level
  allowlist (me/org-requests/invitations/recovery/account/credentials/
  devices/auth); Active users with no workspace → 403 no_workspace;
  SuperAdmin exempt (ACC-03)
- GetRootFolder: Personal auto-tenant creation removed for regular users
  (defensive 403 no_workspace fallback); kept for SuperAdmin console
  convenience — now persisted via ExecuteUpdate (accessor.User is
  AsNoTracking, #44 class; tenant saved before user FK update)
- RegisterVerify: AdminDid bootstrap no longer creates the Personal
  tenant — SuperAdmin provisions tenants through the platform workflow

TDD (§2.1): UserStatusGatingTests + AdminDidRegistrationTests written
first — red at 6 failures (gating absent, Personal tenant still created),
green after implementation. FK-order + AsNoTracking bugs found and fixed
during green (documented in test comments).

Also: WebAuthn PRF spike (task 0.2) deferred to Phase 2 E2E per decision
(issue #10 closed with rationale; fallback = passphrase-first baseline).

Verified: 3 consecutive zero-failure runs (754/754, Release).

🤖 Generated with [ZCode](https://zcode.ai)

Co-Authored-By: ZCode <noreply@anthropic.com>
Author
Owner

ponytail-review (§2.4 AI first-pass) — Verdict: Ship.

What this change does: introduces the Pending account state and blocks tenant-scoped file APIs for Pending/no-workspace users at the single middleware choke point (SsdidAuthMiddleware), with an account-level allowlist; removes the Personal auto-tenant creation from both bootstrap paths (GetRootFolder kept for SuperAdmin console convenience).

Checked: gate placement is AFTER suspended-check and BEFORE MFA-pending handling (correct precedence — pending is orthogonal to mfa); allowlist covers all account-level endpoints a founder needs (me/org-requests/invitations/recovery/account/credentials/devices/auth/health); IsTenantScoped prefix list matches the file-family route groups (folders/files/shares/activity) — notifications/users/tenants/devices intentionally NOT gated (downstream membership checks handle those, per ACC-01 'file/share APIs' wording); SuperAdmin exemption keyed on SystemRole (never user-input); the ExecuteUpdate tenant-provisioning now saves the tenant BEFORE the user FK update (bug found during green); no prod secrets touched.

Notes (not blocking): the 403 problem bodies use the bare codes (org_approval_pending / no_workspace) as detail — the SRS acceptance asserts those exact strings ✓; a later pass can add typed problem codes via AppError for consistency with handler-shaped errors.

Not checked: real-browser Login v2 rendering of the pending/no-workspace states (Phase 2 E2E); Postgres parity for the enum string-mapping (string-mapped, no migration needed).

**ponytail-review (§2.4 AI first-pass) — Verdict: Ship.** What this change does: introduces the Pending account state and blocks tenant-scoped file APIs for Pending/no-workspace users at the single middleware choke point (SsdidAuthMiddleware), with an account-level allowlist; removes the Personal auto-tenant creation from both bootstrap paths (GetRootFolder kept for SuperAdmin console convenience). Checked: gate placement is AFTER suspended-check and BEFORE MFA-pending handling (correct precedence — pending is orthogonal to mfa); allowlist covers all account-level endpoints a founder needs (me/org-requests/invitations/recovery/account/credentials/devices/auth/health); IsTenantScoped prefix list matches the file-family route groups (folders/files/shares/activity) — notifications/users/tenants/devices intentionally NOT gated (downstream membership checks handle those, per ACC-01 'file/share APIs' wording); SuperAdmin exemption keyed on SystemRole (never user-input); the ExecuteUpdate tenant-provisioning now saves the tenant BEFORE the user FK update (bug found during green); no prod secrets touched. Notes (not blocking): the 403 problem bodies use the bare codes (org_approval_pending / no_workspace) as detail — the SRS acceptance asserts those exact strings ✓; a later pass can add typed problem codes via AppError for consistency with handler-shaped errors. Not checked: real-browser Login v2 rendering of the pending/no-workspace states (Phase 2 E2E); Postgres parity for the enum string-mapping (string-mapped, no migration needed).
amiryahaya deleted branch feat/1.1-user-status-gating 2026-11-04 18:38:58 +01:00
Sign in to join this conversation.
No description provided.