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)
committerLucas Gass <lucas@bywatersolutions.com>
Wed, 24 Jan 2024 17:33:44 +0000 (17:33 +0000)
commit38e1c2a951f766c46a370f0c1b27fd9eeadf27d7
tree894d063327f17f60c219c7a1f7fc4d700d65204a
parent1f50091a06517e4098c7f802b6933f17f583900c
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: Lucas Gass <lucas@bywatersolutions.com>
C4/Auth.pm
C4/Auth_with_cas.pm
C4/Auth_with_ldap.pm
C4/Auth_with_shibboleth.pm
C4/ILSDI/Services.pm