]> git.koha-community.org Git - koha.git/commit
Bug 30962: REST API: Add endpoint /auth/password/validation
authorDavid Cook <dcook@prosentient.com.au>
Fri, 17 Jun 2022 04:43:44 +0000 (04:43 +0000)
committerJacob O'Mara <jacob.omara@ptfs-europe.com>
Mon, 6 Feb 2023 16:19:59 +0000 (16:19 +0000)
commit26061075deee2e7e08ba307515956ec8794cfafa
treebb7853f33f243c03d09637d2e7e4ee93796f89f9
parentc638ce42a59cc575c78eb2e77baffaadbcede3ec
Bug 30962: REST API: Add endpoint /auth/password/validation

This patch adds an endpoint for /auth/password/validation

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/auth/password/validation -d '{ "username": "<koha_username">, "password": "<koha_password>" }' -v
4. Note "204 No Content" response
5. curl -XPOST -H "Content-Type: application/json" -u <koha_user>:<koha_password> http://localhost:8081/api/v1/auth/password/validation -d '{ "username": "<koha_username">, "password": "this is definitely not the password" }' -v
6. Note "400 Bad Request" response and error message {"error":"Validation failed"}

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit a8a356404c197e45eedc6c01847cf1811a1cc037)
Signed-off-by: Jacob O'Mara <jacob.omara@ptfs-europe.com>
Koha/REST/V1/Auth/Password.pm [new file with mode: 0644]
api/v1/swagger/paths/auth.yaml
api/v1/swagger/swagger.yaml