[Koha-bugs] [Bug 30962] REST API: Add endpoint /patrons/:patron_id/check_password

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Jun 17 21:09:33 CEST 2022


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30962

David Nind <david at davidnind.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #136215|0                           |1
        is obsolete|                            |

--- Comment #8 from David Nind <david at davidnind.com> ---
Created attachment 136300
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=136300&action=edit
Bug 30962: REST API: Add endpoint /patrons/:patron_id/check_password

This patch adds an endpoint for /patrons/:patron_id/check_password

This allows a third-party, using an authenticated and authorized Koha
API user, to check if the username and password given by a user is
correct in Koha.

For example, a Keycloak extension can be created using its
User Storage SPI to use Koha as the user database for Keycloak. This
API allows us to authenticate the user as a particular Koha user - without
creating a Koha user session for them.

Test plan:
0. Apply patch and koha-plack --restart kohadev
1. Go to
http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=RESTBasicAuth
2. Enable "RESTBasicAuth"
3. Run the following commands while substituting correct values for <koha_user>
and <koha_password>
3. curl -XPOST -H "Content-Type: application/json" -u
<koha_user>:<koha_password>
http://localhost:8081/api/v1/patrons/51/check_password -d '{ "password":
"<koha_password>" }' -v
4. Note "200 OK" response
5. curl -XPOST -H "Content-Type: application/json" -u
<koha_user>:<koha_password>
http://localhost:8081/api/v1/patrons/51/check_password -d '{ "password": "this
is definitely not the password" }' -v
6. Note "400 Bad Request" response and error message {"error":"Invalid
password"}

Signed-off-by: David Nind <david at davidnind.com>

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.


More information about the Koha-bugs mailing list