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

(-)a/C4/Auth.pm (-1 / +23 lines)
Lines 35-40 use Koha::AuthUtils qw(hash_password); Link Here
35
use POSIX qw/strftime/;
35
use POSIX qw/strftime/;
36
use List::MoreUtils qw/ any /;
36
use List::MoreUtils qw/ any /;
37
use Encode qw( encode is_utf8);
37
use Encode qw( encode is_utf8);
38
use Net::CIDR;
38
39
39
# use utf8;
40
# use utf8;
40
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout $shib $shib_login);
41
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout $shib $shib_login);
Lines 52-58 BEGIN { Link Here
52
    @ISA       = qw(Exporter);
53
    @ISA       = qw(Exporter);
53
    @EXPORT    = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions);
54
    @EXPORT    = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions);
54
    @EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &checkpw_internal &checkpw_hash
55
    @EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &checkpw_internal &checkpw_hash
55
      &get_all_subpermissions &get_user_subpermissions
56
      &get_all_subpermissions &get_user_subpermissions &in_ipset
56
    );
57
    );
57
    %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
58
    %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
58
    $ldap      = C4::Context->config('useldapserver') || 0;
59
    $ldap      = C4::Context->config('useldapserver') || 0;
Lines 2021-2026 sub getborrowernumber { Link Here
2021
    return 0;
2022
    return 0;
2022
}
2023
}
2023
2024
2025
=head2 in_ipset
2026
2027
  $flags = ($ipset);
2028
2029
C<$ipset> A space separated string describing an IP set. Can include single IPs or ranges
2030
2031
Returns 1 if the remote address is in the provided ipset, or 0 otherwise.
2032
2033
=cut
2034
2035
sub in_ipset {
2036
	my ($ipset) = @_;
2037
	my @allowedipranges = split(' ', $ipset);
2038
	if (scalar @allowedipranges > 0) {
2039
    unless (Net::CIDR::cidrlookup($ENV{'REMOTE_ADDR'}, Net::CIDR::range2cidr(@allowedipranges))) {
2040
			return 0;
2041
		}
2042
	}
2043
	return 1;
2044
} 
2045
2024
END { }    # module clean-up code here (global destructor)
2046
END { }    # module clean-up code here (global destructor)
2025
1;
2047
1;
2026
__END__
2048
__END__
(-)a/C4/Installer/PerlDependencies.pm (+5 lines)
Lines 782-787 our $PERL_DEPS = { Link Here
782
        'required' => '1',
782
        'required' => '1',
783
        'min_ver'  => '1.10',
783
        'min_ver'  => '1.10',
784
    },
784
    },
785
    'Net::CIDR'    => {
786
        'usage'    => 'Core',
787
        'required' => '1',
788
        'min_ver'  => '0.15',
789
    },
785
};
790
};
786
791
787
1;
792
1;
(-)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 393-398 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
393
('SCOUserJS','',NULL,'Define custom javascript for inclusion in the SCO module','free'),
393
('SCOUserJS','',NULL,'Define custom javascript for inclusion in the SCO module','free'),
394
('SearchMyLibraryFirst','0',NULL,'If ON, OPAC searches return results limited by the user\'s library by default if they are logged in','YesNo'),
394
('SearchMyLibraryFirst','0',NULL,'If ON, OPAC searches return results limited by the user\'s library by default if they are logged in','YesNo'),
395
('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo'),
395
('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo'),
396
('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'),
396
('SelfCheckHelpMessage','','70|10','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','Textarea'),
397
('SelfCheckHelpMessage','','70|10','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','Textarea'),
397
('SelfCheckReceiptPrompt','1','NULL','If ON, print receipt dialog pops up when self checkout is finished','YesNo'),
398
('SelfCheckReceiptPrompt','1','NULL','If ON, print receipt dialog pops up when self checkout is finished','YesNo'),
398
('SelfCheckTimeout','120','','Define the number of seconds before the Web-based Self Checkout times out a patron','Integer'),
399
('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 698-703 Circulation: Link Here
698
                  yes: Show
698
                  yes: Show
699
                  no: "Don't show"
699
                  no: "Don't show"
700
            - "the print receipt popup dialog when self checkout is finished"
700
            - "the print receipt popup dialog when self checkout is finished"
701
        -
702
            - pref: SelfCheckAllowByIPRanges
703
              class: short
704
            - (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>.)
701
    Course Reserves:
705
    Course Reserves:
702
        -
706
        -
703
            - pref: UseCourseReserves
707
            - pref: UseCourseReserves
(-)a/opac/sco/help.pl (-1 / +8 lines)
Lines 24-34 Link Here
24
use strict;
24
use strict;
25
use warnings;
25
use warnings;
26
use CGI qw ( -utf8 );
26
use CGI qw ( -utf8 );
27
use Net::CIDR;
27
28
28
use C4::Auth   qw(get_template_and_user);
29
use C4::Auth   qw(get_template_and_user in_ipset);
29
use C4::Output qw(output_html_with_http_headers);
30
use C4::Output qw(output_html_with_http_headers);
30
31
31
my $query = new CGI;
32
my $query = new CGI;
33
34
unless ( in_ipset(C4::Context->preference('SelfCheckAllowByIPRanges')) ) {
35
		print $query->redirect("/cgi-bin/koha/opac-main.pl");
36
		exit;
37
}
38
32
my ($template, $borrowernumber, $cookie) = get_template_and_user({
39
my ($template, $borrowernumber, $cookie) = get_template_and_user({
33
    template_name => "sco/help.tt",
40
    template_name => "sco/help.tt",
34
    query => $query,
41
    query => $query,
(-)a/opac/sco/printslip.pl (-1 / +7 lines)
Lines 29-40 It is called from sco-main.pl Link Here
29
use strict;
29
use strict;
30
use warnings;
30
use warnings;
31
use CGI qw ( -utf8 );
31
use CGI qw ( -utf8 );
32
32
use C4::Context;
33
use C4::Context;
33
use C4::Auth qw/:DEFAULT get_session/;
34
use C4::Auth qw/:DEFAULT get_session in_ipset/;
34
use C4::Output;
35
use C4::Output;
35
use C4::Members;
36
use C4::Members;
36
use C4::Koha;
37
use C4::Koha;
37
38
39
unless ( in_ipset(C4::Context->preference('SelfCheckAllowByIPRanges')) ) {
40
		print $query->header(status => '403 Forbidden - functionality not available from your location');
41
		exit;
42
}
43
38
my $input = new CGI;
44
my $input = new CGI;
39
my $sessionID = $input->cookie("CGISESSID");
45
my $sessionID = $input->cookie("CGISESSID");
40
my $session = get_session($sessionID);
46
my $session = get_session($sessionID);
(-)a/opac/sco/sco-main.pl (-1 / +6 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 53-58 unless (C4::Context->preference('WebBasedSelfCheck')) { Link Here
53
    print $query->redirect("/cgi-bin/koha/opac-main.pl");
53
    print $query->redirect("/cgi-bin/koha/opac-main.pl");
54
    exit;
54
    exit;
55
}
55
}
56
unless ( in_ipset(C4::Context->preference('SelfCheckAllowByIPRanges')) ) {
57
		# redirect to OPAC home if self-checkout not permitted from current IP
58
		print $query->redirect("/cgi-bin/koha/opac-main.pl");
59
		exit;
60
}
56
61
57
if (C4::Context->preference('AutoSelfCheckAllowed')) 
62
if (C4::Context->preference('AutoSelfCheckAllowed')) 
58
{
63
{
(-)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
23
use C4::Auth qw(in_ipset);
22
use C4::Service;
24
use C4::Service;
23
use C4::Members;
25
use C4::Members;
24
26
Lines 32-37 unless (C4::Context->preference('ShowPatronImageInWebBasedSelfCheck')) { Link Here
32
    print $query->header(status => '403 Forbidden - displaying patron images in self-check not enabled');
34
    print $query->header(status => '403 Forbidden - displaying patron images in self-check not enabled');
33
    exit;
35
    exit;
34
}
36
}
37
unless ( in_ipset(C4::Context->preference('SelfCheckAllowByIPRanges')) ) {
38
		print $query->header(status => '403 Forbidden - functionality not available from your location');
39
		exit;
40
}
35
41
36
my ($borrowernumber) = C4::Service->require_params('borrowernumber');
42
my ($borrowernumber) = C4::Service->require_params('borrowernumber');
37
43
38
- 

Return to bug 14407