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:
ngqileandClaude Opus 5.5 committed 2026-11-26 22:22:49 +08:00
1 parent ca98d4dc22
commit 92c8ad3b25
4 files changed
+33 -8

No files matched your search

@@ -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.