Bug 34893: ILS-DI can return the wrong patron for AuthenticatePatron
authorKyle M Hall <kyle@bywatersolutions.com>
Fri, 22 Sep 2023 18:20:59 +0000 (14:20 -0400)
committerWainui Witika-Park <wainuiwitikapark@catalyst.net.nz>
Wed, 24 Jan 2024 08:30:00 +0000 (08:30 +0000)
commitcd809940b71b8555fa6d40fe38ff662e5384233e
tree7a118e97e749c1f6eb395847017d63ddab8477e1
parent6b3b894647c54c847390ada6f1c4a9383440ba71
Bug 34893: ILS-DI can return the wrong patron for AuthenticatePatron

Imagine we have a set of users. Some of those users have a NULL userid. We then call AuthenticatePatron from ILS-DI for a patron with a NULL userid, but a valid cardnumber. We call checkpw, which returns the cardnumber and userid. We then call Koha::Patrons->find on the userid *which is null*, meaning the borrowernumber returned is not the correct one, but instead the earliest patron inserted into the database that has a NULL userid.

Test Plan:
1) Give three patrons a userid and a password
2) From the database cli, set all patrons's userid to null
   Run this query: update borrowers set userid = null;
3) Call AuthenticatePatron with username being the 1st patron cardnumber,
   and password being the password you set for that patron
   http://localhost:8080/cgi-bin/koha/ilsdi.pl?service=AuthenticatePatron&username=kohacard&password=koha
4) Note you get back a borrowernumber for a different patron. Refresh the page and the number is correct.
5) Do the same with the 2nd patron. Same issue at 1st and correct number after.
6) Apply this patch
7) Restart all the things!
8) Do the same with the 3rd patron.
9) Note you get the correct borrowernumber! :D
10) prove t/Auth.t t/db_dependent/Auth_with_ldap.t t/Auth_with_shibboleth.t t/db_dependent/Auth_with_cas.t

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz>
C4/Auth.pm
C4/Auth_with_cas.pm
C4/Auth_with_ldap.pm
C4/Auth_with_shibboleth.pm
C4/ILSDI/Services.pm