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

(-)a/C4/Auth.pm (-1 / +25 lines)
Lines 42-47 use POSIX qw/strftime/; Link Here
42
use List::MoreUtils qw/ any /;
42
use List::MoreUtils qw/ any /;
43
use Encode qw( encode is_utf8);
43
use Encode qw( encode is_utf8);
44
use C4::Auth_with_shibboleth;
44
use C4::Auth_with_shibboleth;
45
use Net::CIDR;
45
46
46
# use utf8;
47
# use utf8;
47
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout);
48
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout);
Lines 58-64 BEGIN { Link Here
58
    @ISA       = qw(Exporter);
59
    @ISA       = qw(Exporter);
59
    @EXPORT    = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions);
60
    @EXPORT    = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions);
60
    @EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &checkpw_internal &checkpw_hash
61
    @EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &checkpw_internal &checkpw_hash
61
      &get_all_subpermissions &get_user_subpermissions track_login_daily
62
      &get_all_subpermissions &get_user_subpermissions track_login_daily &in_ipset
62
    );
63
    );
63
    %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
64
    %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
64
    $ldap      = C4::Context->config('useldapserver') || 0;
65
    $ldap      = C4::Context->config('useldapserver') || 0;
Lines 2060-2065 sub haspermission { Link Here
2060
    #FIXME - This fcn should return the failed permission so a suitable error msg can be delivered.
2061
    #FIXME - This fcn should return the failed permission so a suitable error msg can be delivered.
2061
}
2062
}
2062
2063
2064
=head2 in_ipset
2065
2066
  $flags = ($ipset);
2067
2068
C<$ipset> A space separated string describing an IP set. Can include single IPs or ranges
2069
2070
Returns 1 if the remote address is in the provided ipset, or 0 otherwise.
2071
2072
=cut
2073
2074
sub in_ipset {
2075
 my ($ipset) = @_;
2076
 my @allowedipranges = split(' ', $ipset);
2077
 if (scalar @allowedipranges > 0) {
2078
    my @rangelist;
2079
    eval { @rangelist = Net::CIDR::range2cidr(@allowedipranges); }; return 0 if $@;
2080
    unless (Net::CIDR::cidrlookup($ENV{'REMOTE_ADDR'}, @rangelist)) {
2081
      return 0;
2082
    }
2083
 }
2084
 return 1;
2085
}
2086
2063
sub getborrowernumber {
2087
sub getborrowernumber {
2064
    my ($userid) = @_;
2088
    my ($userid) = @_;
2065
    my $userenv = C4::Context->userenv;
2089
    my $userenv = C4::Context->userenv;
(-)a/C4/Installer/PerlDependencies.pm (+5 lines)
Lines 787-792 our $PERL_DEPS = { Link Here
787
        'required' => '0',
787
        'required' => '0',
788
        'min_ver'  => '0.56',
788
        'min_ver'  => '0.56',
789
    },
789
    },
790
    'Net::CIDR'    => {
791
        'usage'    => 'Core',
792
        'required' => '1',
793
        'min_ver'  => '0.15',
794
    },
790
    'Net::SFTP::Foreign' => {
795
    'Net::SFTP::Foreign' => {
791
        'usage'    => 'Edifact',
796
        'usage'    => 'Edifact',
792
        'required' => '0',
797
        'required' => '0',
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 495-500 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
495
('SearchEngine','Zebra','Elasticsearch|Zebra','Search Engine','Choice'),
495
('SearchEngine','Zebra','Elasticsearch|Zebra','Search Engine','Choice'),
496
('SearchMyLibraryFirst','0',NULL,'If ON, OPAC searches return results limited by the user\'s library by default if they are logged in','YesNo'),
496
('SearchMyLibraryFirst','0',NULL,'If ON, OPAC searches return results limited by the user\'s library by default if they are logged in','YesNo'),
497
('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo'),
497
('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo'),
498
('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'),
498
('SelfCheckHelpMessage','','70|10','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','Textarea'),
499
('SelfCheckHelpMessage','','70|10','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','Textarea'),
499
('SelfCheckInMainUserBlock','','70|10','Add a block of HTML that will display on the self check-in screen.','Textarea'),
500
('SelfCheckInMainUserBlock','','70|10','Add a block of HTML that will display on the self check-in screen.','Textarea'),
500
('SelfCheckInModule', 0, NULL, 'Enable the standalone self-checkin module.', 'YesNo'),
501
('SelfCheckInModule', 0, NULL, 'Enable the standalone self-checkin module.', 'YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+4 lines)
Lines 925-930 Circulation: Link Here
925
                  yes: Show
925
                  yes: Show
926
                  no: "Don't show"
926
                  no: "Don't show"
927
            - "the print receipt popup dialog when self checkout is finished"
927
            - "the print receipt popup dialog when self checkout is finished"
928
        -
929
            - pref: SelfCheckAllowByIPRanges
930
              class: short
931
            - (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>.)
928
    Course Reserves:
932
    Course Reserves:
929
        -
933
        -
930
            - pref: UseCourseReserves
934
            - pref: UseCourseReserves
(-)a/opac/sco/help.pl (-1 / +6 lines)
Lines 24-33 Link Here
24
use Modern::Perl;
24
use Modern::Perl;
25
use CGI qw ( -utf8 );
25
use CGI qw ( -utf8 );
26
26
27
use C4::Auth   qw(get_template_and_user);
27
use C4::Auth   qw(get_template_and_user in_ipset);
28
use C4::Output qw(output_html_with_http_headers);
28
use C4::Output qw(output_html_with_http_headers);
29
29
30
my $query = new CGI;
30
my $query = new CGI;
31
unless ( in_ipset(C4::Context->preference('SelfCheckAllowByIPRanges')) ) {
32
    print $query->redirect("/cgi-bin/koha/opac-main.pl");
33
    exit;
34
}
35
31
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
36
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
32
    {
37
    {
33
        template_name   => "sco/help.tt",
38
        template_name   => "sco/help.tt",
(-)a/opac/sco/printslip.pl (-1 / +6 lines)
Lines 29-40 It is called from sco-main.pl Link Here
29
use Modern::Perl;
29
use Modern::Perl;
30
use CGI qw ( -utf8 );
30
use CGI qw ( -utf8 );
31
use C4::Context;
31
use C4::Context;
32
use C4::Auth qw/:DEFAULT get_session/;
32
use C4::Auth qw/:DEFAULT get_session in_ipset/;
33
use C4::Output;
33
use C4::Output;
34
use C4::Members;
34
use C4::Members;
35
use C4::Koha;
35
use C4::Koha;
36
36
37
my $input = new CGI;
37
my $input = new CGI;
38
unless ( in_ipset(C4::Context->preference('SelfCheckAllowByIPRanges')) ) {
39
    print $input->header(status => '403 Forbidden - functionality not available from your location');
40
    exit;
41
}
42
38
my $sessionID = $input->cookie("CGISESSID");
43
my $sessionID = $input->cookie("CGISESSID");
39
my $session = get_session($sessionID);
44
my $session = get_session($sessionID);
40
45
(-)a/opac/sco/sco-main.pl (-2 / +8 lines)
Lines 35-41 use Modern::Perl; Link Here
35
35
36
use CGI qw ( -utf8 );
36
use CGI qw ( -utf8 );
37
37
38
use C4::Auth qw(get_template_and_user checkpw);
38
use C4::Auth qw(get_template_and_user checkpw in_ipset);
39
use C4::Koha;
39
use C4::Koha;
40
use C4::Circulation;
40
use C4::Circulation;
41
use C4::Reserves;
41
use C4::Reserves;
Lines 58-64 unless (C4::Context->preference('WebBasedSelfCheck')) { Link Here
58
    exit;
58
    exit;
59
}
59
}
60
60
61
if (C4::Context->preference('AutoSelfCheckAllowed')) 
61
unless ( in_ipset(C4::Context->preference('SelfCheckAllowByIPRanges')) ) {
62
    # redirect to OPAC home if self-checkout not permitted from current IP
63
    print $query->redirect("/cgi-bin/koha/opac-main.pl");
64
    exit;
65
}
66
67
if (C4::Context->preference('AutoSelfCheckAllowed'))
62
{
68
{
63
    my $AutoSelfCheckID = C4::Context->preference('AutoSelfCheckID');
69
    my $AutoSelfCheckID = C4::Context->preference('AutoSelfCheckID');
64
    my $AutoSelfCheckPass = C4::Context->preference('AutoSelfCheckPass');
70
    my $AutoSelfCheckPass = C4::Context->preference('AutoSelfCheckPass');
(-)a/opac/sco/sco-patron-image.pl (-1 / +6 lines)
Lines 18-23 Link Here
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use C4::Auth qw(in_ipset);
21
use C4::Service;
22
use C4::Service;
22
use C4::Members;
23
use C4::Members;
23
use Koha::Patron::Images;
24
use Koha::Patron::Images;
Lines 35-40 unless (C4::Context->preference('ShowPatronImageInWebBasedSelfCheck')) { Link Here
35
    exit;
36
    exit;
36
}
37
}
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 ($borrowernumber) = C4::Service->require_params('borrowernumber');
44
my ($borrowernumber) = C4::Service->require_params('borrowernumber');
39
my ($csrf_token) = C4::Service->require_params('csrf_token');
45
my ($csrf_token) = C4::Service->require_params('csrf_token');
40
46
41
- 

Return to bug 14407