https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44230 --- Comment #3 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 212407 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212407&action=edit Bug 44230: (follow-up) Require permission to suppress the notice and log it The PASSWORD_CHANGE notice is how patrons learn about unexpected password changes. Allowing any API caller to suppress it would let leaked integration credentials take over accounts silently. This patch: * Requires the new `borrowers.suppress_password_change_notice` permission for passing `notify: false` to POST /patrons/{patron_id}/password. The check is done early in the controller, which returns 403 with `error_code: no_permission_for_notice_suppression` otherwise. * Changes the endpoint authorization from the full `borrowers` module to `borrowers.edit_borrowers`, matching the staff interface (members/member-password.pl). Holding the full module implies every `borrowers` subpermission, so with the previous requirement the new permission could never be withheld. * Makes Koha::Patron->set_password always log the password change when the notice is explicitly suppressed, even if BorrowersLog is disabled. The log entry has 'PASSWORD_CHANGE notice suppressed' as info and records who did it. * Documents the requirements in the endpoint description. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ updatedatabase k$ yarn api:bundle k$ prove xt/api.t \ t/db_dependent/Koha/Patron.t \ t/db_dependent/Koha/Patrons.t \ t/db_dependent/api/v1/patrons_password.t => SUCCESS: Tests pass! 3. Restart services: k$ restart_all 4. Enable RESTBasicAuth, disable BorrowersLog 5. Create a staff user with only the 'edit_borrowers' permission and set a password for them 6. Using that user, set a patron's password passing "notify": false: $ curl -u <user>:<password> -X POST \ http://localhost:8081/api/v1/patrons/<patron_id>/password \ -H 'Content-Type: application/json' \ -d '{"password":"Abcd1234!","password_2":"Abcd1234!","notify":false}' => SUCCESS: 403, error_code is no_permission_for_notice_suppression 7. Repeat 6 without "notify" => SUCCESS: 200, the password is changed 8. Grant the user the 'suppress_password_change_notice' permission and repeat 6 => SUCCESS: 200, no 'Password change' notice is generated 9. Go to Tools > Log viewer, filter by module 'Patrons' => SUCCESS: The 'CHANGE PASS' entry for the patron says 'PASSWORD_CHANGE notice suppressed' and the librarian is recorded, even though BorrowersLog is disabled 10. Sign off :-D Assisted-by: Opus 5.5 (Anthropic) -- You are receiving this mail because: You are watching all bug changes.