View | Details | Raw Unified | Return to bug 14407
Collapse All | Expand All

(-)a/C4/Auth.pm (-1 / +23 lines)
Lines 38-43 use Koha::Libraries; Link Here
38
use POSIX qw/strftime/;
38
use POSIX qw/strftime/;
39
use List::MoreUtils qw/ any /;
39
use List::MoreUtils qw/ any /;
40
use Encode qw( encode is_utf8);
40
use Encode qw( encode is_utf8);
41
use Net::CIDR;
41
42
42
# use utf8;
43
# use utf8;
43
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout $shib $shib_login);
44
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout $shib $shib_login);
Lines 54-60 BEGIN { Link Here
54
    @ISA       = qw(Exporter);
55
    @ISA       = qw(Exporter);
55
    @EXPORT    = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions);
56
    @EXPORT    = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions);
56
    @EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &checkpw_internal &checkpw_hash
57
    @EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &checkpw_internal &checkpw_hash
57
      &get_all_subpermissions &get_user_subpermissions
58
      &get_all_subpermissions &get_user_subpermissions &in_ipset
58
    );
59
    );
59
    %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
60
    %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
60
    $ldap      = C4::Context->config('useldapserver') || 0;
61
    $ldap      = C4::Context->config('useldapserver') || 0;
Lines 2031-2036 sub haspermission { Link Here
2031
    #FIXME - This fcn should return the failed permission so a suitable error msg can be delivered.
2032
    #FIXME - This fcn should return the failed permission so a suitable error msg can be delivered.
2032
}
2033
}
2033
2034
2035
=head2 in_ipset
2036
2037
  $flags = ($ipset);
2038
2039
C<$ipset> A space separated string describing an IP set. Can include single IPs or ranges
2040
2041
Returns 1 if the remote address is in the provided ipset, or 0 otherwise.
2042
2043
=cut
2044
2045
sub in_ipset {
2046
 my ($ipset) = @_;
2047
 my @allowedipranges = split(' ', $ipset);
2048
 if (scalar @allowedipranges > 0) {
2049
    unless (Net::CIDR::cidrlookup($ENV{'REMOTE_ADDR'}, Net::CIDR::range2cidr(@allowedipranges))) {
2050
     return 0;
2051
   }
2052
 }
2053
 return 1;
2054
}
2055
2034
sub getborrowernumber {
2056
sub getborrowernumber {
2035
    my ($userid) = @_;
2057
    my ($userid) = @_;
2036
    my $userenv = C4::Context->userenv;
2058
    my $userenv = C4::Context->userenv;
(-)a/C4/Installer/PerlDependencies.pm (+5 lines)
Lines 777-782 our $PERL_DEPS = { Link Here
777
        'required' => '0',
777
        'required' => '0',
778
        'min_ver'  => '0.56',
778
        'min_ver'  => '0.56',
779
    },
779
    },
780
    'Net::CIDR'    => {
781
        'usage'    => 'Core',
782
        'required' => '1',
783
        'min_ver'  => '0.15',
784
    },
780
    'Net::SFTP::Foreign' => {
785
    'Net::SFTP::Foreign' => {
781
        'usage'    => 'Edifact',
786
        'usage'    => 'Edifact',
782
        'required' => '0',
787
        'required' => '0',
(-)a/installer/data/mysql/atomicupdate/bug_14407-add_selfcheckallowbyipranges_syspref.sql (+2 lines)
Line 0 Link Here
1
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES
2
	('SelfCheckAllowByIPRanges','',NULL,'(Leave blank if not used. Use ranges or simple ip addresses separated by spaces, like <code>192.168.1.1 192.168.0.0/24</code>.)','Short');
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 436-441 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
436
('SearchEngine','Zebra','Elasticsearch|Zebra','Search Engine','Choice'),
436
('SearchEngine','Zebra','Elasticsearch|Zebra','Search Engine','Choice'),
437
('SearchMyLibraryFirst','0',NULL,'If ON, OPAC searches return results limited by the user\'s library by default if they are logged in','YesNo'),
437
('SearchMyLibraryFirst','0',NULL,'If ON, OPAC searches return results limited by the user\'s library by default if they are logged in','YesNo'),
438
('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo'),
438
('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo'),
439
('SelfCheckAllowByIPRanges','',NULL,'(Leave blank if not used. Use ranges or simple ip addresses separated by spaces, like <code>192.168.1.1 192.168.0.0/24</code>.)','Short'),
439
('SelfCheckHelpMessage','','70|10','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','Textarea'),
440
('SelfCheckHelpMessage','','70|10','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','Textarea'),
440
('SelfCheckReceiptPrompt','1','NULL','If ON, print receipt dialog pops up when self checkout is finished','YesNo'),
441
('SelfCheckReceiptPrompt','1','NULL','If ON, print receipt dialog pops up when self checkout is finished','YesNo'),
441
('SelfCheckTimeout','120','','Define the number of seconds before the Web-based Self Checkout times out a patron','Integer'),
442
('SelfCheckTimeout','120','','Define the number of seconds before the Web-based Self Checkout times out a patron','Integer'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+4 lines)
Lines 745-750 Circulation: Link Here
745
                  yes: Show
745
                  yes: Show
746
                  no: "Don't show"
746
                  no: "Don't show"
747
            - "the print receipt popup dialog when self checkout is finished"
747
            - "the print receipt popup dialog when self checkout is finished"
748
        -
749
            - pref: SelfCheckAllowByIPRanges
750
              class: short
751
            - (Leave blank if not used. Use ranges or simple ip addresses separated by spaces, like <code>192.168.1.1 192.168.0.0/24</code>.)
748
    Course Reserves:
752
    Course Reserves:
749
        -
753
        -
750
            - pref: UseCourseReserves
754
            - pref: UseCourseReserves
(-)a/opac/sco/help.pl (-1 / +7 lines)
Lines 25-34 use strict; Link Here
25
use warnings;
25
use warnings;
26
use CGI qw ( -utf8 );
26
use CGI qw ( -utf8 );
27
27
28
use C4::Auth   qw(get_template_and_user);
28
use C4::Auth   qw(get_template_and_user in_ipset);
29
use C4::Output qw(output_html_with_http_headers);
29
use C4::Output qw(output_html_with_http_headers);
30
30
31
my $query = new CGI;
31
my $query = new CGI;
32
33
unless ( in_ipset(C4::Context->preference('SelfCheckAllowByIPRanges')) ) {
34
		print $query->redirect("/cgi-bin/koha/opac-main.pl");
35
		exit;
36
}
37
32
my ($template, $borrowernumber, $cookie) = get_template_and_user({
38
my ($template, $borrowernumber, $cookie) = get_template_and_user({
33
    template_name => "sco/help.tt",
39
    template_name => "sco/help.tt",
34
    query => $query,
40
    query => $query,
(-)a/opac/sco/printslip.pl (-1 / +6 lines)
Lines 30-40 use strict; Link Here
30
use warnings;
30
use warnings;
31
use CGI qw ( -utf8 );
31
use CGI qw ( -utf8 );
32
use C4::Context;
32
use C4::Context;
33
use C4::Auth qw/:DEFAULT get_session/;
33
use C4::Auth qw/:DEFAULT get_session in_ipset/;
34
use C4::Output;
34
use C4::Output;
35
use C4::Members;
35
use C4::Members;
36
use C4::Koha;
36
use C4::Koha;
37
37
38
unless ( in_ipset(C4::Context->preference('SelfCheckAllowByIPRanges')) ) {
39
		print $query->header(status => '403 Forbidden - functionality not available from your location');
40
		exit;
41
}
42
38
my $input = new CGI;
43
my $input = new CGI;
39
my $sessionID = $input->cookie("CGISESSID");
44
my $sessionID = $input->cookie("CGISESSID");
40
my $session = get_session($sessionID);
45
my $session = get_session($sessionID);
(-)a/opac/sco/sco-main.pl (-2 / +8 lines)
Lines 37-43 use warnings; Link Here
37
use CGI qw ( -utf8 );
37
use CGI qw ( -utf8 );
38
use Digest::MD5 qw(md5_base64);
38
use Digest::MD5 qw(md5_base64);
39
39
40
use C4::Auth qw(get_template_and_user checkpw);
40
use C4::Auth qw(get_template_and_user checkpw in_ipset);
41
use C4::Koha;
41
use C4::Koha;
42
use C4::Circulation;
42
use C4::Circulation;
43
use C4::Reserves;
43
use C4::Reserves;
Lines 56-62 unless (C4::Context->preference('WebBasedSelfCheck')) { Link Here
56
    exit;
56
    exit;
57
}
57
}
58
58
59
if (C4::Context->preference('AutoSelfCheckAllowed')) 
59
unless ( in_ipset(C4::Context->preference('SelfCheckAllowByIPRanges')) ) {
60
		# redirect to OPAC home if self-checkout not permitted from current IP
61
		print $query->redirect("/cgi-bin/koha/opac-main.pl");
62
		exit;
63
}
64
65
if (C4::Context->preference('AutoSelfCheckAllowed'))
60
{
66
{
61
    my $AutoSelfCheckID = C4::Context->preference('AutoSelfCheckID');
67
    my $AutoSelfCheckID = C4::Context->preference('AutoSelfCheckID');
62
    my $AutoSelfCheckPass = C4::Context->preference('AutoSelfCheckPass');
68
    my $AutoSelfCheckPass = C4::Context->preference('AutoSelfCheckPass');
(-)a/opac/sco/sco-patron-image.pl (-1 / +6 lines)
Lines 19-24 Link Here
19
19
20
use strict;
20
use strict;
21
use warnings;
21
use warnings;
22
use C4::Auth qw(in_ipset);
22
use C4::Service;
23
use C4::Service;
23
use C4::Members;
24
use C4::Members;
24
use Koha::Patron::Images;
25
use Koha::Patron::Images;
Lines 34-39 unless (C4::Context->preference('ShowPatronImageInWebBasedSelfCheck')) { Link Here
34
    exit;
35
    exit;
35
}
36
}
36
37
38
unless ( in_ipset(C4::Context->preference('SelfCheckAllowByIPRanges')) ) {
39
		print $query->header(status => '403 Forbidden - functionality not available from your location');
40
		exit;
41
}
42
37
my ($borrowernumber) = C4::Service->require_params('borrowernumber');
43
my ($borrowernumber) = C4::Service->require_params('borrowernumber');
38
44
39
my $patron_image = Koha::Patron::Images->find($borrowernumber);
45
my $patron_image = Koha::Patron::Images->find($borrowernumber);
40
- 

Return to bug 14407