Files
co-lite/openspec/changes/archive/2026-12-01-fix-company-scope-fail-closed/proposal.md
T

1.4 KiB

Why

The whole-branch review of add-company-scoping (PR #25) found that the code trusts the "every non-super admin belongs to a company" rule instead of enforcing it. An admin user with no company who is not a super admin (left over from before companies, or created by a direct DB edit) is scoped to all companies. A company user who still holds role 1 skips every module check and is treated as a super admin when reading super admins' emails.

What Changes

  • Company scope fails closed: an admin with no company who is not a super admin gets 403 COMPANY_REQUIRED on every company-scoped admin endpoint instead of seeing all companies.
  • The admin module check grants all modules only to a super admin (no company and role 1), not to any holder of role 1.
  • The email detail hides super admins' emails from every caller who is not a super admin, using the same super-admin test.

Capabilities

New Capabilities

Modified Capabilities

  • company-scoping: adds the "Invalid admins fail closed" requirement for the two invalid states.

Impact

  • solvway-mobile-api: AdminCompanyScope, AppAccessAspect, AdminEmailService.
  • No API shape, schema or portal change. Valid users (super admins, and staff with a company) see no difference.
  • Deferred: the capture event list still loads only the first 100 enabled events (marked ponytail: in AdminEventLeadService).