GRI-2105: let an admin set a new password for a user #256

Merged
vivy merged 4 commits from fix/GRI-2105-admin-set-password into dev 2026-11-15 22:21:10 +00:00
Member

Summary

  • PATCH /api/v1/users/{user_id} accepts an optional password field: an admin reset of another user's password. Absent leaves the password unchanged, the same "absent = unchanged" convention name/group_id/campus_id already use.
  • Hashed with the existing PasswordHasher (Argon2id), same as account creation.
  • Validation matches create_user: under 8 characters is 400 weak_password, nothing changes.
  • Gated by the existing require_users_manage — no new permission, since users.manage is already unscoped and is exactly "may manage that user."
  • On a successful password change, every one of the target's sessions is ended (new auth::delete_sessions_for_user), not only the caller's own — a session acquired before the reset no longer authenticates afterwards.
  • No current-password confirmation: this is an admin acting on another account, not a self-service change.
  • Updated plan/server/rest-api.md.

Full shape discussed on forge issue #226 comment 13177.

Test plan

Written myself from the candidate acceptance tests in #226 comment 13177 (no pre-existing QA tests for this), in their own commit before the implementation, in crates/server/tests/permissions_integration.rs:

  • admin sets a new password for another user → 200, target logs in with it, the old password is refused
  • the target's existing session cookie no longer authenticates after the reset
  • a password under 8 characters is rejected (400 weak_password), nothing changes
  • a caller without users.manage gets 403
  • an unknown user_id gets 404
  • an absent password field leaves the password unchanged

Verified locally: SIGNAGE_TEST_DATABASE_URL=... ./scripts/local-gates.sh --rust-only — every gate passed.

## Summary - `PATCH /api/v1/users/{user_id}` accepts an optional `password` field: an admin reset of another user's password. Absent leaves the password unchanged, the same "absent = unchanged" convention `name`/`group_id`/`campus_id` already use. - Hashed with the existing `PasswordHasher` (Argon2id), same as account creation. - Validation matches `create_user`: under 8 characters is `400 weak_password`, nothing changes. - Gated by the existing `require_users_manage` — no new permission, since `users.manage` is already unscoped and is exactly "may manage that user." - On a successful password change, every one of the target's sessions is ended (new `auth::delete_sessions_for_user`), not only the caller's own — a session acquired before the reset no longer authenticates afterwards. - No current-password confirmation: this is an admin acting on another account, not a self-service change. - Updated `plan/server/rest-api.md`. Full shape discussed on forge issue #226 comment 13177. ## Test plan Written myself from the candidate acceptance tests in #226 comment 13177 (no pre-existing QA tests for this), in their own commit before the implementation, in `crates/server/tests/permissions_integration.rs`: - [x] admin sets a new password for another user → 200, target logs in with it, the old password is refused - [x] the target's existing session cookie no longer authenticates after the reset - [x] a password under 8 characters is rejected (400 `weak_password`), nothing changes - [x] a caller without `users.manage` gets 403 - [x] an unknown `user_id` gets 404 - [x] an absent `password` field leaves the password unchanged Verified locally: `SIGNAGE_TEST_DATABASE_URL=... ./scripts/local-gates.sh --rust-only` — every gate passed.
GRI-2105: let an admin set a new password for a user
All checks were successful
CI / the pre-push hook (pull_request) Successful in 4s
CI / cargo fmt (pull_request) Successful in 5s
CI / install.sh client upgrade (pull_request) Successful in 8s
CI / cargo deny (pull_request) Successful in 16s
CI / cargo deny advisories (pull_request) Successful in 24s
CI / repository boundary (pull_request) Successful in 5s
CI / cargo clippy (pull_request) Successful in 1m27s
CI / frontend-web (pull_request) Successful in 1m14s
CI / cargo test (pull_request) Successful in 4m28s
CI / CI (pull_request) Successful in 2s
CI / Notify gate failed (pull_request) Has been skipped
2b79c3c925
vivy approved these changes 2026-11-15 21:24:26 +00:00
Dismissed
vivy left a comment

Correct and well tested. Two non-blocking notes for a follow-up: (1) delete_sessions_for_user runs after the transaction commits, so if it fails the password is changed and old sessions stay; it can go inside users::update's transaction. (2) An admin who resets their own password also ends their own session; fine, but the panel (#258) should expect the 401.

Correct and well tested. Two non-blocking notes for a follow-up: (1) delete_sessions_for_user runs after the transaction commits, so if it fails the password is changed and old sessions stay; it can go inside users::update's transaction. (2) An admin who resets their own password also ends their own session; fine, but the panel (#258) should expect the 401.
Merge branch 'dev' into fix/GRI-2105-admin-set-password
All checks were successful
CI / the pre-push hook (pull_request) Successful in 5s
CI / install.sh client upgrade (pull_request) Successful in 11s
CI / cargo fmt (pull_request) Successful in 4s
CI / cargo deny (pull_request) Successful in 23s
CI / cargo clippy (pull_request) Successful in 2m7s
CI / cargo deny advisories (pull_request) Successful in 26s
CI / repository boundary (pull_request) Successful in 6s
CI / frontend-web (pull_request) Successful in 1m25s
CI / cargo test (pull_request) Successful in 4m28s
CI / CI (pull_request) Successful in 2s
CI / Notify gate failed (pull_request) Has been skipped
e117bb0562
Merge branch 'dev' into fix/GRI-2105-admin-set-password
All checks were successful
CI / the pre-push hook (pull_request) Successful in 5s
CI / cargo fmt (pull_request) Successful in 5s
CI / install.sh client upgrade (pull_request) Successful in 11s
CI / cargo deny (pull_request) Successful in 23s
CI / cargo deny advisories (pull_request) Successful in 21s
CI / cargo clippy (pull_request) Successful in 2m0s
CI / repository boundary (pull_request) Successful in 7s
CI / frontend-web (pull_request) Successful in 1m23s
CI / cargo test (pull_request) Successful in 4m42s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 2s
dee5dfe45f
vivy dismissed vivy's review 2026-11-15 22:04:20 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

vivy merged commit 4ccc194e49 into dev 2026-11-15 22:21:10 +00:00
vivy deleted branch fix/GRI-2105-admin-set-password 2026-11-15 22:21:10 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grimoirix/grimoire-of-digital-signage!256
No description provided.