Admin can set a new password for a user #226
Labels
No labels
Area/Backend
Area/Database
Area/Docs
Area/Frontend
Area/Infra
Area/Security
Area/Tests
Area/Tooling
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Lang/Python
Lang/Rust
Lang/Shell
Lang/SQL
Lang/TypeScript
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Routing
Auto
Routing
Hold
Routing
Human
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage#226
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PATCH /users/{id}accepts only name, group_id and campus_id. There is no way to change a user's password, so a forgotten password locks the colleague out.Expected: Users > Edit has "Set new password" (admin types it twice, same length rules as create). Server: a password field on PATCH (or a separate endpoint), hashed the same way as create, and the user's other sessions are ended. Only roles that may manage that user can do it. Tests.
Read the current code:
crates/server/src/users.rsmatches this issue's description exactly.UpdateUserRequestonPATCH /api/v1/users/{user_id}has onlyname,group_id,campus_id— no password field, and no admin password-reset path exists anywhere (backend or frontend).users.manageis a global permission with no device/campus scope (Permission::accepts_device_scopeputsUsersManagein the unscoped group), so "only roles that may manage that user" is already exactly whatrequire_users_manageenforces — there is no narrower "manage that user" grant in this app to add.I checked the whole repo (
crates/server/tests,frontend-web/src) for any existing test or stub for this — none. Per our process, implementation starts from tests the QA engineer writes, not from this description alone, so I'm not coding yet.Proposed shape, so a test can be written against something concrete — CTO, please confirm or redirect:
PATCH /users/{user_id}with an optionalpassword: Option<String>field (reuse the endpoint rather than add a new one — it already carries one other mutable field (name) with the same "absent = unchanged" convention).create_user— reject under 8 characters (weak_password).PasswordHasherextension, same as creation.sessionsfor thatuser_id(needs a newauth::storefunction; none exists today beyond single-tokendelete_session) — so the target's other active sessions end, per the issue.require_users_manage, already inupdate_user.Candidate acceptance tests for the QA engineer:
weak_password), and nothing changes.users.managegets 403.user_idgets 404.passwordfield leaves the password unchanged (consistent withname/group_id/campus_id's existing "absent = unchanged" behaviour).Marking this blocked on the CTO so the QA engineer can write the acceptance tests (or confirm the shape above and send tests over); I'll implement against them as soon as they land.
The issue has two halves, and they are in two pull requests:
PATCH /users/{id}takes an optionalpassword. It is hashed the same way as on create and refused under 8 characters (weak_password), onlyusers.managemay do it, and all of the user's sessions are ended.93622df), before the code (9fc4978).local-gates.sh --frontend-onlypassed every gate.Merge order: #256 before #258. Without #256 the server silently ignores
password, and the panel would report success when nothing changed. CI is running on both. This issue closes when both are in dev.QA review of the two GRI-2105 PRs for this issue.
#256 (Nyssa, backend) — fail-first verified, CI green
Tests map 1:1 to the candidate acceptance tests in comment 13177 (1+2 combined into one test):
an_admin_password_reset_lets_the_target_log_in_with_the_new_password_and_refuses_the_old_one— AC 1+2an_admin_password_reset_ends_the_targets_other_sessions— AC 3an_admin_password_reset_rejects_a_password_under_eight_characters— AC 4a_caller_without_users_manage_cannot_reset_a_password— AC 5a_password_reset_on_an_unknown_user_returns_404— AC 6an_absent_password_field_leaves_the_password_unchanged— AC 7I checked out the tests-only commit (
ab3a3b4, before the implementation commit2b79c3c) in a scratch working tree and ran the three behaviour-changing tests against it with a real database:The other three pass trivially pre-implementation (404 on unknown user, 403 without
users.manage, and an ignored unknown field leaving things unchanged are all pre-existing behaviour) — that's expected, not a gap. CI on2b79c3c9is fully green.#258 (Soulwarden, panel) — good AAA tests, CI green
Four tests in
UsersScreen.test.tsx, committed before the implementation (93622dfbefore9fc4978), one per criterion: sets the password, mismatch is refused, too-short is refused, empty fields leave it alone. Tests assert on visible text/roles, not internals. CI green.Verdict: both ready. Merge #256 before #258, as both PR bodies already say (the panel's test suite doesn't exercise a live server, so the ordering is only a correctness/sequencing concern for the real deploy, not something that would show up as a CI failure).
Both halves pass forge CI (22:20Z): server PR #256 on
dee5dfe4and the Users > Edit 'Set new password' panel PR #258 on9fc4978, both fj ci exit 0, both mergeable into dev. Merge order matters: #256 first, then #258. Without #256 the server ignores the password field and the panel would report a false success. I close this issue once both are in dev.Update at 22:51Z. The server half, #256, is in
dev. Vivy merged it at 22:21Z (merge4ccc194).The panel half, #258, is the only part still open.
devwas merged into it as0a8516c9. CI on that commit passed (fj ci 258exit 0), and the forge says it can be merged intodev.@vivy: #258 is ready for you to merge. Since #256 is already in
dev, merging it now is safe.Both halves are in dev: server #256, panel #258. Closing.
Done. Both halves are in dev, measured at 23:22Z:
fj landed GRI-2105exit 0, ahead=0. Server side (#256, Nyssa): PATCH /users/{id} takes an optional password. It is hashed like create, uses the same weak_password rule, requires users.manage, and ends the target user's sessions. Vivy merged it at 22:21Z (4ccc194). Panel (#258): Users > Edit has 'Set new password', typed twice, with the same length rule. Vivy merged it at 22:55Z (e0f6e211). CI was green on both before the merge, and the acceptance tests went in their own commits before the code (ab3a3b4,93622df).