docs(openspec): close admin self-escalation found in review
A non-super admin cannot change their own roles or the grants of a role they hold, hidden roles cannot be assigned, and the direct set-password endpoint goes. 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
ca98d4dc22
commit
92c8ad3b25
4 files changed
+33
-8
No files matched your search
@@ -23,7 +23,7 @@ The system SHALL let an admin with `BO_ROLES` list, create and rename admin role
|
||||
|
||||
### Requirement: Role permissions
|
||||
|
||||
The system SHALL let an admin with `BO_ROLES` 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.
|
||||
The system SHALL let an admin with `BO_ROLES` 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. An admin who is not super admin SHALL NOT change the grants of a role they hold.
|
||||
|
||||
#### Scenario: Grant Users module
|
||||
|
||||
@@ -32,11 +32,11 @@ The system SHALL let an admin with `BO_ROLES` choose, for a role, which back-off
|
||||
- **THEN** users with `ROLE_SALES` see Users in the sidebar after their next login or session refresh
|
||||
- **AND** `GET /api/admin/users` responds 200 for them
|
||||
|
||||
#### Scenario: Self lock-out
|
||||
#### Scenario: Own role
|
||||
|
||||
- **GIVEN** the admin's only role that grants `BO_ROLES` is the role being edited
|
||||
- **WHEN** they remove `BO_ROLES` from it and save
|
||||
- **THEN** the save is refused with a message, so no admin loses access to role management by mistake
|
||||
- **GIVEN** an admin who is not super admin and holds `ROLE_SALES`
|
||||
- **WHEN** they change the module grants of `ROLE_SALES` and save
|
||||
- **THEN** the save is refused with a message, so no admin can widen their own access or lock themselves out of role management
|
||||
|
||||
### Requirement: Back-office module set
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ The system SHALL let an admin with `BO_USERS` create an admin user with name, us
|
||||
|
||||
### Requirement: Edit and deactivate user
|
||||
|
||||
The system SHALL let an admin with `BO_USERS` change a user's name, email, roles and active state. A deactivated user SHALL NOT be able to log in, and a session they already hold SHALL be refused on its next `/api/admin/**` call. An admin SHALL NOT be able to deactivate their own account.
|
||||
The system SHALL let an admin with `BO_USERS` change a user's name, email, roles and active state. A deactivated user SHALL NOT be able to log in, and a session they already hold SHALL be refused on its next `/api/admin/**` call. An admin SHALL NOT be able to deactivate their own account. An admin who is not super admin SHALL NOT change the roles on their own account. No admin SHALL assign `ROLE_ADMIN` or `ROLE_MEMBER` when creating or editing a user.
|
||||
|
||||
#### Scenario: Deactivate
|
||||
|
||||
@@ -49,9 +49,20 @@ The system SHALL let an admin with `BO_USERS` change a user's name, email, roles
|
||||
- **WHEN** an admin tries to deactivate their own account
|
||||
- **THEN** the save is refused with a message
|
||||
|
||||
#### Scenario: Own roles
|
||||
|
||||
- **GIVEN** an admin who is not super admin and holds `ROLE_SALES`
|
||||
- **WHEN** they save their own account with a different set of roles
|
||||
- **THEN** the save is refused with a message and their roles are unchanged
|
||||
|
||||
#### Scenario: Hidden roles
|
||||
|
||||
- **WHEN** an admin creates or edits a user with `ROLE_ADMIN` or `ROLE_MEMBER` in the roles
|
||||
- **THEN** the save is refused with a message
|
||||
|
||||
### Requirement: Admin-triggered password reset
|
||||
|
||||
The system SHALL let an admin with `BO_USERS` reset another user's password, which emails the user a temporary password and requires a change at next login.
|
||||
The system SHALL let an admin with `BO_USERS` reset another user's password, which emails the user a temporary password and requires a change at next login. The system SHALL NOT let an admin set another user's password to a value the admin chooses.
|
||||
|
||||
#### Scenario: Reset
|
||||
|
||||
@@ -59,6 +70,11 @@ The system SHALL let an admin with `BO_USERS` reset another user's password, whi
|
||||
- **THEN** `sales1`'s old password stops working
|
||||
- **AND** a temporary password is emailed to `sales1`'s email address
|
||||
|
||||
#### Scenario: No direct password set
|
||||
|
||||
- **WHEN** an admin calls `POST /api/admin/users/{id}/changePassword`
|
||||
- **THEN** the endpoint does not exist and no password changes
|
||||
|
||||
### Requirement: Company membership
|
||||
|
||||
Every admin user SHALL belong to exactly one company. The company SHALL be set by the system from the creating admin, never from the request.
|
||||
|
||||
Reference in new issue
Block a user