Bugzilla – Attachment 166975 Details for
Bug 26176
AutoLocation is badly named
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26176: Rename AutoLocation to StaffLoginRestrictBranchByIP
Bug-26176-Rename-AutoLocation-to-StaffLoginRestric.patch (text/plain), 14.33 KB, created by
Nick Clemens (kidclamp)
on 2024-05-21 13:59:10 UTC
(
hide
)
Description:
Bug 26176: Rename AutoLocation to StaffLoginRestrictBranchByIP
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-05-21 13:59:10 UTC
Size:
14.33 KB
patch
obsolete
>From 1c6060577ee9fc76ff8131e5a8afe593d4a57d3a Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 21 May 2024 13:44:47 +0000 >Subject: [PATCH] Bug 26176: Rename AutoLocation to > StaffLoginRestrictBranchByIP > >This patch sets AutoLocation to be called StaffLoginRestrictBranchByIP. >The new name is chosen to reflect the new pref StaffLoginBranchBasedOnIP. > >Also this patch corrects the order of sysprefs in installer file. > >To test: >Follow test plans on bug 36665 and bug 35890 and confirm that the preferences >continue to work as expected >Confirm the descriptions of the prefs in the staff interface match the behaviors expected >--- > C4/Auth.pm | 10 ++++---- > C4/UsageStats.pm | 2 +- > installer/data/mysql/mandatory/sysprefs.sql | 4 +-- > .../intranet-tmpl/prog/en/includes/header.inc | 4 +-- > .../en/modules/admin/preferences/admin.pref | 4 +-- > t/db_dependent/Auth.t | 25 +++++++++---------- > 6 files changed, 24 insertions(+), 25 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 9adf500476e..f92578ad41f 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -498,7 +498,7 @@ sub get_template_and_user { > advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), > AllowMultipleCovers => C4::Context->preference('AllowMultipleCovers'), > AmazonCoverImages => C4::Context->preference("AmazonCoverImages"), >- AutoLocation => C4::Context->preference("AutoLocation"), >+ StaffLoginRestrictBranchByIP => C4::Context->preference("StaffLoginRestrictBranchByIP"), > can_see_cataloguing_module => haspermission( $user, get_cataloguing_page_permissions() ) ? 1 : 0, > canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'), > EasyAnalyticalRecords => C4::Context->preference('EasyAnalyticalRecords'), >@@ -1216,7 +1216,7 @@ sub checkauth { > } > if ( $type ne 'opac' ) { > my $branches = { map { $_->branchcode => $_->unblessed } Koha::Libraries->search->as_list }; >- if ( C4::Context->preference('AutoLocation') ) { >+ if ( C4::Context->preference('StaffLoginRestrictBranchByIP') ) { > # we have to check they are coming from the right ip range > my $domain = $branches->{$branchcode}->{'branchip'}; > $domain =~ s|\.\*||g; >@@ -1236,10 +1236,10 @@ sub checkauth { > > if ( > ( >- !C4::Context->preference('AutoLocation') >+ !C4::Context->preference('StaffLoginRestrictBranchByIP') > && C4::Context->preference('StaffLoginBranchBasedOnIP') > ) >- || ( C4::Context->preference('AutoLocation') && $auth_state ne 'failed' ) >+ || ( C4::Context->preference('StaffLoginRestrictBranchByIP') && $auth_state ne 'failed' ) > ) > { > my @branchcodes = sort { lc $a cmp lc $b } keys %$branches; >@@ -1438,7 +1438,7 @@ sub checkauth { > IntranetUserCSS => C4::Context->preference("IntranetUserCSS"), > IntranetUserJS => C4::Context->preference("IntranetUserJS"), > IndependentBranches => C4::Context->preference("IndependentBranches"), >- AutoLocation => C4::Context->preference("AutoLocation"), >+ StaffLoginRestrictBranchByIP => C4::Context->preference("StaffLoginRestrictBranchByIP"), > wrongip => $info{'wrongip'}, > PatronSelfRegistration => C4::Context->preference("PatronSelfRegistration"), > PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"), >diff --git a/C4/UsageStats.pm b/C4/UsageStats.pm >index 56877dd8aff..f45a3d4a855 100644 >--- a/C4/UsageStats.pm >+++ b/C4/UsageStats.pm >@@ -146,7 +146,7 @@ sub _shared_preferences { > noItemTypeImages > OpacNoItemTypeImages > virtualshelves >- AutoLocation >+ StaffLoginRestrictBranchByIP > IndependentBranches > SessionStorage > Persona >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index d4c4acde1b0..23c704af56f 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -90,7 +90,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('AutoCreditNumber', '', '', 'Automatically generate a number for account credits', 'Choice'), > ('AutoEmailNewUser','0',NULL,'Send an email to newly created patrons.','YesNo'), > ('AutoLinkBiblios','0',NULL,'If enabled, link biblio to authorities on creation and edit','YesNo'), >-('AutoLocation','0',NULL,'If ON, IP authentication is enabled, blocking access to the staff interface from unauthorized IP addresses','YesNo'), > ('AutomaticCheckinAutoFill','0',NULL,'Automatically fill the next hold with an automatic check in.','YesNo'), > ('AutomaticConfirmTransfer','0',NULL,'Defines whether transfers should be automatically confirmed at checkin if modal dismissed','YesNo'), > ('AutomaticItemReturn','1',NULL,'If ON, Koha will automatically set up a transfer of this item to its homebranch','YesNo'), >@@ -736,8 +735,9 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('StaffDetailItemSelection', '1', NULL, 'Enable item selection in record detail page', 'YesNo'), > ('StaffHighlightedWords','1','','Highlight search terms on staff interface','YesNo'), > ('StaffLangSelectorMode','footer','top|both|footer','Select the location to display the language selector in staff interface','Choice'), >-('StaffLoginInstructions', '', NULL, 'HTML to go into the login box for the staff interface','Free'), > ('StaffLoginBranchBasedOnIP', '0','', 'Set the logged in branch for the user based on their current IP','YesNo'), >+('StaffLoginInstructions', '', NULL, 'HTML to go into the login box for the staff interface','Free'), >+('StaffLoginRestrictBranchByIP','0',NULL,'If ON, IP authentication is enabled, blocking access to the staff interface from unauthorized IP addresses based on branch','YesNo'), > ('StaffSearchResultsDisplayBranch','holdingbranch','holdingbranch|homebranch','Controls the display of the home or holding branch for staff search results','Choice'), > ('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the staff interface','Integer'), > ('staffShibOnly','0','','If ON enables shibboleth only authentication for the staff client','YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >index 78cacbd6ed1..0a58182e555 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >@@ -95,7 +95,7 @@ > [% SET is_superlibrarian = CAN_user_superlibrarian ? 'is_superlibrarian' : '' %] > <span class="loggedinusername [% is_superlibrarian | html %]">[% logged_in_user.userid | html %]</span> > <span class="loggedincategorycode content_hidden">[% logged_in_user.categorycode | html %]</span> >- [% IF ( AutoLocation ) %] >+ [% IF ( StaffLoginRestrictBranchByIP ) %] > <brand> > [% Branches.GetLoggedInBranchname | html %] > </brand> >@@ -133,7 +133,7 @@ > <span class="loggedinusername">[% logged_in_user.userid | html %]</span> > </li> > <li class="loggedin-menu-label"> >- [% IF ( AutoLocation ) %] >+ [% IF ( StaffLoginRestrictBranchByIP ) %] > <brand> > [% Branches.GetLoggedInBranchname | html %] > </brand> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >index 164bd564528..20697bfec7f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/admin.pref >@@ -92,7 +92,7 @@ Administration: > - Adding d will specify it in days, e.g. 1d is timeout of one day. > - > - "Require staff to log in from a computer in the IP address range specified by their library or the branch chosen at login (if any): " >- - pref: AutoLocation >+ - pref: StaffLoginRestrictBranchByIP > default: 0 > choices: > 1: "Yes" >@@ -115,7 +115,7 @@ Administration: > 1: "Yes" > 0: "No" > - "Note: If IPs overlap, the first found match will be used." >- - 'This setting will be overridden by <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=AutoLocation">AutoLocation</a> system preference. In the event of multiple branches with matching IPs, branchcode (alphabetically) will be the tie breaker.' >+ - 'This setting will be overridden by <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=StaffLoginRestrictBranchByIP">StaffLoginRestrictBranchByIP</a> system preference. In the event of multiple branches with matching IPs, branchcode (alphabetically) will be the tie breaker.' > # PostgreSQL is supported by CGI::Session but not by Koha. > - > - "Storage of login session information: " >diff --git a/t/db_dependent/Auth.t b/t/db_dependent/Auth.t >index 153b91a5d6b..633375d4718 100755 >--- a/t/db_dependent/Auth.t >+++ b/t/db_dependent/Auth.t >@@ -1298,8 +1298,8 @@ subtest 'StaffLoginBranchBasedOnIP' => sub { > > $schema->storage->txn_begin; > >- t::lib::Mocks::mock_preference( 'AutoLocation', 0 ); >- t::lib::Mocks::mock_preference( 'StaffLoginBranchBasedOnIP', 0 ); >+ t::lib::Mocks::mock_preference( 'StaffLoginRestrictBranchByIP', 0 ); >+ t::lib::Mocks::mock_preference( 'StaffLoginBranchBasedOnIP', 0 ); > > my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1 } } ); > my $branch = $builder->build_object( { class => 'Koha::Libraries', value => { branchip => "127.0.0.1" } } ); >@@ -1331,16 +1331,16 @@ subtest 'StaffLoginBranchBasedOnIP' => sub { > $session = C4::Auth::get_session($sessionID); > is( $session->param('branch'), $branch->branchcode, "Logged in branch is set based on the IP from REMOTE_ADDR " ); > >- # AutoLocation overrides StaffLoginBranchBasedOnIP >- t::lib::Mocks::mock_preference( 'AutoLocation', 1 ); >+ # StaffLoginRestrictBranchByIP overrides StaffLoginBranchBasedOnIP >+ t::lib::Mocks::mock_preference( 'StaffLoginRestrictBranchByIP', 1 ); > ( $userid, $cookie, $sessionID, $flags, $template ) = > C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); > is( > $template->{VARS}->{wrongip}, 1, >- "AutoLocation prevents StaffLoginBranchBasedOnIP from logging user in to another branch" >+ "StaffLoginRestrictBranchByIP prevents StaffLoginBranchBasedOnIP from logging user in to another branch" > ); > >- t::lib::Mocks::mock_preference( 'AutoLocation', 0 ); >+ t::lib::Mocks::mock_preference( 'StaffLoginRestrictBranchByIP', 0 ); > my $other_branch = $builder->build_object( > { class => 'Koha::Libraries', value => { branchip => "127.0.0.1", branchcode => "z" . $branch->branchcode } } ); > ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' ); >@@ -1353,13 +1353,13 @@ subtest 'StaffLoginBranchBasedOnIP' => sub { > > }; > >-subtest 'AutoLocation' => sub { >+subtest 'StaffLoginRestrictBranchByIP' => sub { > > plan tests => 10; > > $schema->storage->txn_begin; > >- t::lib::Mocks::mock_preference( 'AutoLocation', 0 ); >+ t::lib::Mocks::mock_preference( 'StaffLoginRestrictBranchByIP', 0 ); > > my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { flags => 1 } } ); > my $password = 'password'; >@@ -1377,12 +1377,12 @@ subtest 'AutoLocation' => sub { > > $ENV{REMOTE_ADDR} = '127.0.0.1'; > my ( $userid, $cookie, $sessionID, $flags ) = C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' ); >- is( $userid, $patron->userid, "Standard login without AutoLocation" ); >+ is( $userid, $patron->userid, "Standard login without StaffLoginRestrictBranchByIP" ); > > my $template; >- t::lib::Mocks::mock_preference( 'AutoLocation', 1 ); >+ t::lib::Mocks::mock_preference( 'StaffLoginRestrictBranchByIP', 1 ); > >- # AutoLocation: "Require staff to log in from a computer in the IP address range specified by their library (if any)" >+ # StaffLoginRestrictBranchByIP: "Require staff to log in from a computer in the IP address range specified by their library (if any)" > $patron->library->branchip('')->store; # There is none, allow access from anywhere > ( $userid, $cookie, $sessionID, $flags, $template ) = > C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet' ); >@@ -1419,7 +1419,7 @@ subtest 'AutoLocation' => sub { > $session = C4::Auth::get_session($sessionID); > is( > $session->param('branch'), $other_library->branchcode, >- "AutoLocation allows specifying a branch as long as the IP matches" >+ "StaffLoginRestrictBranchByIP allows specifying a branch as long as the IP matches" > ); > > $other_library->branchip('129.0.0.1')->store; >@@ -1427,7 +1427,6 @@ subtest 'AutoLocation' => sub { > C4::Auth::checkauth( $cgi, 0, { catalogue => 1 }, 'intranet', undef, undef, { do_not_print => 1 } ); > is( $template->{VARS}->{wrongip}, 1, "Login denied when branch specified and IP does not match branch IP" ); > >- > $ENV{REMOTE_ADDR} = '129.0.0.1'; # Set current IP to match other_branch > $cgi->param( 'branch', undef ); # Do not pass a branch > $patron->library->branchip('')->store; # Unset user branch IP, to allow IP matching on any branch >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26176
:
166975
|
166976
|
167019
|
167020
|
167072
|
167091
|
167092
|
167093
|
167094
|
167095
|
167096
|
167114
|
167162