Bug 37104 - Block AnonymousPatron from logging into anything
Summary: Block AnonymousPatron from logging into anything
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Authentication (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Sam Lau
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords:
Depends on: 36679
Blocks:
  Show dependency treegraph
 
Reported: 2024-06-17 16:15 UTC by Lucas Gass (lukeg)
Modified: 2024-09-24 07:14 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This prevents the anonymous patron from logging into the OPAC and staff interface. (The anonymous patron used for anonymous suggestions and checkout history is set using the AnonymousPatron system preference.)
Version(s) released in:
24.11.00
Circulation function:


Attachments
Bug 37104: Block AnonymousPatron from logging into staff interface and OPAC (4.28 KB, patch)
2024-06-17 16:57 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 37104: Block AnonymousPatron from logging into staff interface and OPAC (4.28 KB, patch)
2024-06-17 17:05 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 37104: Block AnonymousPatron from logging into staff interface and OPAC (4.75 KB, patch)
2024-06-17 18:04 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 37104: (Follow up) Restructure checkpw code (936 bytes, patch)
2024-06-17 19:40 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 37104: Unit tests (3.19 KB, patch)
2024-06-17 19:40 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 37104: Block AnonymousPatron from logging into staff interface and OPAC (4.80 KB, patch)
2024-06-18 00:18 UTC, David Nind
Details | Diff | Splinter Review
Bug 37104: (Follow up) Restructure checkpw code (984 bytes, patch)
2024-06-18 00:18 UTC, David Nind
Details | Diff | Splinter Review
Bug 37104: Unit tests (3.24 KB, patch)
2024-06-18 00:18 UTC, David Nind
Details | Diff | Splinter Review
Bug 37104: Unit tests (3.31 KB, patch)
2024-06-28 15:49 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 37104: Block AnonymousPatron from logging into staff interface and OPAC (4.88 KB, patch)
2024-06-28 15:49 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 37104: (Follow up) Restructure checkpw code (1.58 KB, patch)
2024-06-28 15:49 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 37104: (Follow up) Checks for unitialized value of 'anonymous_patron' system pref (894 bytes, patch)
2024-07-08 14:51 UTC, Sam Lau
Details | Diff | Splinter Review
Bug 37104: (Follow up) Checks for unitialized value of 'anonymous_patron' system pref (1.03 KB, patch)
2024-07-09 15:01 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 37104: (Follow up) Checks for unitialized value of 'anonymous_patron' system pref (1.03 KB, patch)
2024-07-10 08:07 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Lucas Gass (lukeg) 2024-06-17 16:15:29 UTC
In Bug 36679 we blocked the AnonymousPatron from logging into SCO. The AnonymousPatron should not log in to anything, staff interface/OPAC/SCO.
Comment 1 Sam Lau 2024-06-17 16:57:10 UTC
Created attachment 167793 [details] [review]
Bug 37104: Block AnonymousPatron from logging into staff interface and OPAC

This patch blocks the patron set as the anonymous patron from logging into the staff interface and OPAC.

To test:
1) In Administration->sys. pref, make sure AnonymousPatron is pointed to an account.
2) Visit that patron's page and set their permissions to superlibrarian ("Access to all librarian functions")
3) Ensure that you know the username and password for this patron and can log in.
4) Visit the OPAC, attempt to log-in with your anon patron.
5) Note that you can log in and nothing happens.
6) Visit the staff interface, attempt to log-in with anon patron.
7) Once again, note that you are able to log-in with no issue.
8) Apply patch and restart_all
9) Attempt to log into the OPAC and staff interface with the patron again.
10) This time, you should get an error message on both pages saying, "Error: You can't log in as the anonymous patron!"
Comment 2 Sam Lau 2024-06-17 17:05:12 UTC
Created attachment 167795 [details] [review]
Bug 37104: Block AnonymousPatron from logging into staff interface and OPAC

This patch blocks the patron set as the anonymous patron from logging into the staff interface and OPAC.

To test:
1) In Administration->sys. pref, make sure AnonymousPatron is pointed to an account.
2) Visit that patron's page and set their permissions to superlibrarian ("Access to all librarian functions")
3) Ensure that you know the username and password for this patron and can log in.
4) Visit the OPAC, attempt to log-in with your anon patron.
5) Note that you can log in and nothing happens.
6) Visit the staff interface, attempt to log-in with anon patron.
7) Once again, note that you are able to log-in with no issue.
8) Apply patch and restart_all
9) Attempt to log into the OPAC and staff interface with the patron again.
10) This time, you should get an error message on both pages saying, "Error: You can't log in as the anonymous patron!"
Comment 3 Sam Lau 2024-06-17 18:04:09 UTC
Created attachment 167798 [details] [review]
Bug 37104: Block AnonymousPatron from logging into staff interface and OPAC

This patch blocks the patron set as the anonymous patron from logging into the staff interface and OPAC.

To test:
1) In Administration->sys. pref, make sure AnonymousPatron is pointed to an account.
2) Visit that patron's page and set their permissions to superlibrarian ("Access to all librarian functions")
3) Ensure that you know the username and password for this patron and can log in.
4) Visit the OPAC, attempt to log-in with your anon patron.
5) Note that you can log in and nothing happens.
6) Visit the staff interface, attempt to log-in with anon patron.
7) Once again, note that you are able to log-in with no issue.
8) Apply patch and restart_all
9) Attempt to log into the OPAC and staff interface with the patron again.
10) This time, you should get an error message on both pages saying, "Error: You can't log in as the anonymous patron!"
Comment 4 Sam Lau 2024-06-17 19:40:53 UTC
Created attachment 167801 [details] [review]
Bug 37104: (Follow up) Restructure checkpw code
Comment 5 Sam Lau 2024-06-17 19:40:55 UTC
Created attachment 167802 [details] [review]
Bug 37104: Unit tests

prove t/db-dependent/Auth.t
Comment 6 David Nind 2024-06-18 00:18:07 UTC
Created attachment 167811 [details] [review]
Bug 37104: Block AnonymousPatron from logging into staff interface and OPAC

This patch blocks the patron set as the anonymous patron from logging into the staff interface and OPAC.

To test:
1) In Administration->sys. pref, make sure AnonymousPatron is pointed to an account.
2) Visit that patron's page and set their permissions to superlibrarian ("Access to all librarian functions")
3) Ensure that you know the username and password for this patron and can log in.
4) Visit the OPAC, attempt to log-in with your anon patron.
5) Note that you can log in and nothing happens.
6) Visit the staff interface, attempt to log-in with anon patron.
7) Once again, note that you are able to log-in with no issue.
8) Apply patch and restart_all
9) Attempt to log into the OPAC and staff interface with the patron again.
10) This time, you should get an error message on both pages saying, "Error: You can't log in as the anonymous patron!"

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 David Nind 2024-06-18 00:18:09 UTC
Created attachment 167812 [details] [review]
Bug 37104: (Follow up) Restructure checkpw code

Signed-off-by: David Nind <david@davidnind.com>
Comment 8 David Nind 2024-06-18 00:18:12 UTC
Created attachment 167813 [details] [review]
Bug 37104: Unit tests

prove t/db-dependent/Auth.t

Signed-off-by: David Nind <david@davidnind.com>
Comment 9 David Nind 2024-06-18 00:21:36 UTC
Testing notes (using KTD):
1. To run the tests (underscore, rather than a dash): prove t/db_dependent/Auth.t
Comment 10 Martin Renvoize (ashimema) 2024-06-28 15:49:23 UTC
Created attachment 168268 [details] [review]
Bug 37104: Unit tests

prove t/db-dependent/Auth.t

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 11 Martin Renvoize (ashimema) 2024-06-28 15:49:26 UTC
Created attachment 168269 [details] [review]
Bug 37104: Block AnonymousPatron from logging into staff interface and OPAC

This patch blocks the patron set as the anonymous patron from logging into the staff interface and OPAC.

To test:
1) In Administration->sys. pref, make sure AnonymousPatron is pointed to an account.
2) Visit that patron's page and set their permissions to superlibrarian ("Access to all librarian functions")
3) Ensure that you know the username and password for this patron and can log in.
4) Visit the OPAC, attempt to log-in with your anon patron.
5) Note that you can log in and nothing happens.
6) Visit the staff interface, attempt to log-in with anon patron.
7) Once again, note that you are able to log-in with no issue.
8) Apply patch and restart_all
9) Attempt to log into the OPAC and staff interface with the patron again.
10) This time, you should get an error message on both pages saying, "Error: You can't log in as the anonymous patron!"

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 12 Martin Renvoize (ashimema) 2024-06-28 15:49:28 UTC
Created attachment 168270 [details] [review]
Bug 37104: (Follow up) Restructure checkpw code

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 13 Martin Renvoize (ashimema) 2024-06-28 15:50:32 UTC
Thanks Sam, all working as expected now.

QA scripts happy and unit tests passing.

Passing QA
Comment 14 Katrin Fischer 2024-07-01 16:43:38 UTC
my $is_anonymous_patron = $patron && ( $patron->borrowernumber eq $anonymous_patron );

Why not use == instead of eq?
Comment 15 Katrin Fischer 2024-07-01 16:58:43 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 16 Jonathan Druart 2024-07-05 07:19:21 UTC
Found a new warning that seems related to this change.

[WARN] Use of uninitialized value $anonymous_patron in string eq at /kohadevbox/koha/C4/Auth.pm line 2065.
Comment 17 Sam Lau 2024-07-08 14:51:07 UTC
Created attachment 168592 [details] [review]
Bug 37104: (Follow up) Checks for unitialized value of 'anonymous_patron' system pref
Comment 18 Sam Lau 2024-07-08 14:55:14 UTC
(In reply to Jonathan Druart from comment #16)
> Found a new warning that seems related to this change.
> 
> [WARN] Use of uninitialized value $anonymous_patron in string eq at
> /kohadevbox/koha/C4/Auth.pm line 2065.

The issue is due to the 'AnonymousPatron' system preference being a text entry bod, so it could be an empty string. Needed to first check if it is initialized. What do you think of this, Jonathan?
Comment 19 Jonathan Druart 2024-07-09 15:00:28 UTC
(In reply to Sam Lau from comment #18)
> (In reply to Jonathan Druart from comment #16)
> > Found a new warning that seems related to this change.
> > 
> > [WARN] Use of uninitialized value $anonymous_patron in string eq at
> > /kohadevbox/koha/C4/Auth.pm line 2065.
> 
> The issue is due to the 'AnonymousPatron' system preference being a text
> entry bod, so it could be an empty string. Needed to first check if it is
> initialized. What do you think of this, Jonathan?

Yes, but why did you replace '==' with 'eq'?
It shouldn't make much differences, but the other occurrences are using eq.
Comment 20 Jonathan Druart 2024-07-09 15:01:48 UTC
Created attachment 168666 [details] [review]
Bug 37104: (Follow up) Checks for unitialized value of 'anonymous_patron' system pref

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
JD Amended patch: replace '==' with 'eq' for consistency with other
occurrences.
Comment 21 Jonathan Druart 2024-07-10 08:07:47 UTC
Created attachment 168694 [details] [review]
Bug 37104: (Follow up) Checks for unitialized value of 'anonymous_patron' system pref

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
JD Amended patch: replace '==' with 'eq' for consistency with other
occurrences.
Comment 22 Katrin Fischer 2024-08-13 14:11:19 UTC
I think I missed this follow-up - grabbing it now.
Comment 23 Jonathan Druart 2024-09-24 07:14:20 UTC
(In reply to Katrin Fischer from comment #22)
> I think I missed this follow-up - grabbing it now.

I would add a search on > Pushed to Main that that have the "additional_work_needed" kw.
Then it should be removed when you dealt with it :)