Bugzilla – Attachment 184591 Details for
Bug 36561
Inappropriate permission for "/api/v1/auth/password/validation"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36561: Make /auth/password/validation use new permission
Bug-36561-Make-authpasswordvalidation-use-new-perm.patch (text/plain), 2.35 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-07-24 12:36:08 UTC
(
hide
)
Description:
Bug 36561: Make /auth/password/validation use new permission
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-07-24 12:36:08 UTC
Size:
2.35 KB
patch
obsolete
>From aa4bc4d1b075299ae8f32a97bf5241352b36271a Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Wed, 23 Jul 2025 18:26:08 -0300 >Subject: [PATCH] Bug 36561: Make /auth/password/validation use new permission > >This patch updates the /auth/password/validation endpoint to use the new >api_validate_password permission instead of the generic borrowers >permission. > >This provides more granular control over who can use the password >validation API endpoint. > >To test: >1. Apply this patches >2. Rebuild the API spec > $ ktd --shell > k$ yarn api:bundle >3. Run: > $ ktd --shell > k$ prove t/db_dependent/api/v1/password_validation.t >=> SUCCESS: Tests pass! >4. Sign off :-D > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > api/v1/swagger/paths/auth.yaml | 2 +- > t/db_dependent/api/v1/password_validation.t | 15 ++++++++++++++- > 2 files changed, 15 insertions(+), 2 deletions(-) > >diff --git a/api/v1/swagger/paths/auth.yaml b/api/v1/swagger/paths/auth.yaml >index 052565e4de6..700023cf555 100644 >--- a/api/v1/swagger/paths/auth.yaml >+++ b/api/v1/swagger/paths/auth.yaml >@@ -1183,4 +1183,4 @@ > $ref: ../swagger.yaml#/definitions/error > x-koha-authorization: > permissions: >- borrowers: "1" >+ borrowers: api_validate_password >diff --git a/t/db_dependent/api/v1/password_validation.t b/t/db_dependent/api/v1/password_validation.t >index 74b025d96db..6e59d52a51c 100755 >--- a/t/db_dependent/api/v1/password_validation.t >+++ b/t/db_dependent/api/v1/password_validation.t >@@ -40,9 +40,22 @@ $schema->storage->txn_begin; > my $librarian = $builder->build_object( > { > class => 'Koha::Patrons', >- value => { flags => 2**4 } # borrowers flag = 4 >+ value => { flags => 0 } # No top-level permissions > } > ); >+ >+# Ensure our librarian can see users from all branches (once list_borrowers is added) >+$builder->build( >+ { >+ source => 'UserPermission', >+ value => { >+ borrowernumber => $librarian->borrowernumber, >+ module_bit => 4, >+ code => 'api_validate_password', >+ }, >+ } >+); >+ > my $password = 'thePassword123'; > $librarian->set_password( { password => $password, skip_validation => 1 } ); > my $userid = $librarian->userid; >-- >2.50.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36561
:
165447
|
165713
|
165718
|
166545
|
166546
|
166547
|
166549
|
166550
|
166551
|
184590
| 184591 |
184630