fix: fail closed for admins outside the company model #27

Merged
ngqile merged 1 commits from fix-company-scope-fail-closed into main 2026-12-01 01:32:09 +00:00
Owner

Follow-up to #25 (whole-branch review minors). OpenSpec change fix-company-scope-fail-closed.

What changes

  • AdminCompanyScope.scope / requireCompanyForCreate: an admin with no company who is not a super admin gets 403 COMPANY_REQUIRED instead of an all-companies scope.
  • AppAccessAspect: the module check is skipped only for AdminCompanyScope.isSuper (no company and role 1), not for any holder of role 1.
  • AdminEmailService: super admins' emails are hidden from every caller who is not a real super admin (same test).

Valid users (super admins, staff with a company) see no difference. Login, first-login, password change, logout and /me don't use the scope, so an invalid user can still sign in and sign out.

Tests

  • New: AdminCompanyScopeTest.companyLessNonSuper_isRefusedEverywhere, AppAccessAspectAdminTest.companyUserHoldingRole1_getsOnlyTheirOtherRolesModules, AdminEmailServiceTest.detail_companyCallerHoldingRole1_isNotSuper (all red first).
  • Fixture-only updates to tests that used now-invalid users (company-less staff, company user holding role 1); no assertion weakened (Opus review).
  • mvn -T 1C -q -pl solvway-mobile-api verify: green, 715 tests.

Notes

  • A company user holding role 1 is refused only while role 1 itself has no BO module grants in modules_roles. True locally; real environments unverified.
  • Deferred: the capture event list still loads only the first 100 enabled events.
  • No UI change; no Playwright run.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM

Follow-up to #25 (whole-branch review minors). OpenSpec change `fix-company-scope-fail-closed`. ## What changes - `AdminCompanyScope.scope` / `requireCompanyForCreate`: an admin with no company who is not a super admin gets 403 `COMPANY_REQUIRED` instead of an all-companies scope. - `AppAccessAspect`: the module check is skipped only for `AdminCompanyScope.isSuper` (no company and role 1), not for any holder of role 1. - `AdminEmailService`: super admins' emails are hidden from every caller who is not a real super admin (same test). Valid users (super admins, staff with a company) see no difference. Login, first-login, password change, logout and `/me` don't use the scope, so an invalid user can still sign in and sign out. ## Tests - New: `AdminCompanyScopeTest.companyLessNonSuper_isRefusedEverywhere`, `AppAccessAspectAdminTest.companyUserHoldingRole1_getsOnlyTheirOtherRolesModules`, `AdminEmailServiceTest.detail_companyCallerHoldingRole1_isNotSuper` (all red first). - Fixture-only updates to tests that used now-invalid users (company-less staff, company user holding role 1); no assertion weakened (Opus review). - `mvn -T 1C -q -pl solvway-mobile-api verify`: green, 715 tests. ## Notes - A company user holding role 1 is refused only while role 1 itself has no BO module grants in `modules_roles`. True locally; real environments unverified. - Deferred: the capture event list still loads only the first 100 enabled events. - No UI change; no Playwright run. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
ngqile added 1 commit 2026-12-01 01:32:05 +00:00
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
ngqile merged commit a1aa906a66 into main 2026-12-01 01:32:09 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ngqile/co-lite#27