Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
54 lines
2.5 KiB
Markdown
54 lines
2.5 KiB
Markdown
# admin-roles Specification
|
|
|
|
## Purpose
|
|
|
|
Admins with the Roles module define roles and choose which back-office modules each role grants, which controls the menus and endpoints its users reach.
|
|
|
|
## Requirements
|
|
|
|
### Requirement: Role list and edit
|
|
|
|
The system SHALL let any admin with `BO_ROLES` list admin roles, and SHALL let only a super admin create and rename them, because roles are shared by every company. Role names SHALL be unique. The member role and `ROLE_ADMIN` SHALL NOT appear in the list (`ROLE_ADMIN` is attached to every admin automatically and grants no modules).
|
|
|
|
#### Scenario: Create role
|
|
|
|
- **WHEN** a super admin creates role `ROLE_SALES`
|
|
- **THEN** it appears in the role list and can be assigned to users of any company
|
|
|
|
#### Scenario: Duplicate name
|
|
|
|
- **GIVEN** role `ROLE_SALES` exists
|
|
- **WHEN** a super admin creates another role named `ROLE_SALES`
|
|
- **THEN** the save is refused with a message
|
|
|
|
#### Scenario: Company user edits a role
|
|
|
|
- **WHEN** an INS user with `BO_ROLES` creates or renames a role
|
|
- **THEN** the request is refused with 403 and nothing changes
|
|
|
|
### Requirement: Role permissions
|
|
|
|
The system SHALL let only a super admin choose, for a role, which back-office modules it grants, shown as the module tree. Saving SHALL replace the role's module grants with the chosen set. The grants of the super admin role and of `ROLE_ADMIN` SHALL NOT be editable. Admins with `BO_ROLES` who are not super admins SHALL see the grants read-only.
|
|
|
|
#### Scenario: Grant Users module
|
|
|
|
- **GIVEN** role `ROLE_SALES` without `BO_USERS`
|
|
- **WHEN** a super admin grants `BO_USERS` to `ROLE_SALES` and saves
|
|
- **THEN** users with `ROLE_SALES` in every company see Users in the sidebar after their next login or session refresh
|
|
- **AND** `GET /api/admin/users` responds 200 for them
|
|
|
|
#### Scenario: Own role
|
|
|
|
- **GIVEN** an INS user who is not super admin and holds `ROLE_SALES` and `BO_ROLES`
|
|
- **WHEN** they change the module grants of `ROLE_SALES`, or of any other role
|
|
- **THEN** the save is refused with 403 and the grants stay as they were
|
|
|
|
### Requirement: Back-office module set
|
|
|
|
The system SHALL hold Co-Lite's back-office modules in the module table, with a root entry and one entry per admin screen. This change SHALL add `BO_USERS` (Users) and `BO_ROLES` (Roles). Later changes add their own modules.
|
|
|
|
#### Scenario: Seeded modules
|
|
|
|
- **WHEN** the local stack starts from an empty database
|
|
- **THEN** the super admin's sidebar shows Users and Roles and no Tastefully back-office entries
|