[Bug 44312] New: Incorrect user recorded in AuthFailureLog when a SIP account passes the wrong credentials
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44312 Bug ID: 44312 Summary: Incorrect user recorded in AuthFailureLog when a SIP account passes the wrong credentials Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: normal Priority: P5 - low Component: SIP2 Assignee: koha-bugs@lists.koha-community.org Reporter: nick@bywatersolutions.com QA Contact: testopia@bugs.koha-community.org Target Milestone: --- It seems that AuthFailureLog will record the userid of the last successfully logged in SIP account when a failed login attempt is made. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44312 Nick Clemens (kidclamp) <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|koha-bugs@lists.koha-commun |nick@bywatersolutions.com |ity.org | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44312 --- Comment #1 from Nick Clemens (kidclamp) <nick@bywatersolutions.com> --- Created attachment 212733 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212733&action=edit Bug 44312: Don't attribute failed SIP logins to the previous terminal Bug 42847 made login_core clear the leftover session keys on $server before authenticating, but C4::Context->userenv from a previous successful login on the same preforked worker was left in place. When AuthFailureLog (or BorrowersLog) is enabled, a failed SIP login is then logged with action_logs.user set to the previously authenticated terminal instead of 0. This patch unsets the userenv along with the session keys, so only a successful api_auth re-establishes it. A failed login is now logged with user 0, the same as a failed OPAC or staff interface login. Test plan: 1) Enable the AuthFailureLog and AuthSuccessLog system preferences 2) Make sure two SIP accounts exist in SIPconfig.xml with matching staff patrons, e.g. 'koha' (password 'koha') and 'term1' (password 'term1') in KTD, then restart SIP: koha-sip --restart kohadev 3) Connect to the SIP server (telnet localhost 6001 in KTD) and send a successful login for the first account: 9300CNkoha|COkoha|CPCPL| Note you get 941 4) On the same connection (or a new one), send a bad login for the second account: 9300CNterm1|COWRONG|CPCPL| Note you get 940 5) Check the action logs: SELECT user, module, action, object, info FROM action_logs WHERE module IN ('AUTH','MEMBERS') ORDER BY action_id DESC LIMIT 4; 6) Note the AUTH FAILURE row for term1 (and the MEMBERS MODIFY row for login_attempts) has 'user' set to the koha patron's borrowernumber 7) prove t/db_dependent/SIP/MsgType.t 8) Note the new subtest fails 9) Apply this patch and restart SIP 10) prove t/db_dependent/SIP/MsgType.t 11) Note the tests pass 12) Repeat steps 3-5 13) Note the failure rows now have user 0 14) Log in as term1 with the right password and note it still works (941) and is logged under term1's borrowernumber Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44312 jdemuth@roseville.ca.us <jdemuth@roseville.ca.us> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jdemuth@roseville.ca.us -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44312 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44312 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #212733|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44312 --- Comment #2 from David Nind <david@davidnind.com> --- Created attachment 212805 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212805&action=edit Bug 44312: Don't attribute failed SIP logins to the previous terminal Bug 42847 made login_core clear the leftover session keys on $server before authenticating, but C4::Context->userenv from a previous successful login on the same preforked worker was left in place. When AuthFailureLog (or BorrowersLog) is enabled, a failed SIP login is then logged with action_logs.user set to the previously authenticated terminal instead of 0. This patch unsets the userenv along with the session keys, so only a successful api_auth re-establishes it. A failed login is now logged with user 0, the same as a failed OPAC or staff interface login. Test plan: 1) Enable the AuthFailureLog and AuthSuccessLog system preferences 2) Make sure two SIP accounts exist in SIPconfig.xml with matching staff patrons, e.g. 'koha' (password 'koha') and 'term1' (password 'term1') in KTD, then restart SIP: koha-sip --restart kohadev 3) Connect to the SIP server (telnet localhost 6001 in KTD) and send a successful login for the first account: 9300CNkoha|COkoha|CPCPL| Note you get 941 4) On the same connection (or a new one), send a bad login for the second account: 9300CNterm1|COWRONG|CPCPL| Note you get 940 5) Check the action logs: SELECT user, module, action, object, info FROM action_logs WHERE module IN ('AUTH','MEMBERS') ORDER BY action_id DESC LIMIT 4; 6) Note the AUTH FAILURE row for term1 (and the MEMBERS MODIFY row for login_attempts) has 'user' set to the koha patron's borrowernumber 7) prove t/db_dependent/SIP/MsgType.t 8) Note the new subtest fails 9) Apply this patch and restart SIP 10) prove t/db_dependent/SIP/MsgType.t 11) Note the tests pass 12) Repeat steps 3-5 13) Note the failure rows now have user 0 14) Log in as term1 with the right password and note it still works (941) and is logged under term1's borrowernumber Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44312 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com --- Comment #3 from David Nind <david@davidnind.com> --- Testing notes (using KTD): 1. Step 3: Install telnet: sudo apt-get install telnet 2. Steps 7 and 8: This is how I tested this (I'm sure there is probably a better way): - Applied the patch - git checkout origin/main C4/SIP/Sip/MsgType.pm - prove t/db_dependent/SIP/MsgType.t - New test then fails - Reset everything 3. Step 14: 9300CNterm1|COterm1|CPCPL| -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org