fix(mobile-api): fail closed for admins outside the company model
An admin with no company who is not a super admin now gets 403 COMPANY_REQUIRED on every company-scoped request instead of seeing all companies. The module check and the email detail treat only a real super admin (no company and role 1) as super; a company user still holding role 1 gets only what their other roles grant. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
1 parent
7d29d89b3f
commit
998e04b844
12 files changed
+122
-10
No files matched your search
@@ -0,0 +1,23 @@
|
||||
## 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`).
|
||||
Reference in new issue
Block a user