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)
committerKatrin Fischer <katrin.fischer@bsz-bw.de>
Fri, 2 Feb 2024 16:31:46 +0000 (17:31 +0100)
commitc1b94fc0110db53718053a0ff23d52000f304d47
tree84e9837719b9073ced1abf988a91c451ef5582f4
parent795387f5198d2171e694f41d10a6ac7fa3b67139
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: Katrin Fischer <katrin.fischer@bsz-bw.de>
C4/Auth.pm
C4/Auth_with_cas.pm
C4/Auth_with_ldap.pm
C4/Auth_with_shibboleth.pm
C4/ILSDI/Services.pm