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

(-)a/C4/Auth.pm (-1 / +25 lines)
Lines 44-49 use POSIX qw/strftime/; Link Here
44
use List::MoreUtils qw/ any /;
44
use List::MoreUtils qw/ any /;
45
use Encode qw( encode is_utf8);
45
use Encode qw( encode is_utf8);
46
use C4::Auth_with_shibboleth;
46
use C4::Auth_with_shibboleth;
47
use Net::CIDR;
47
48
48
# use utf8;
49
# use utf8;
49
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout);
50
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap $cas $caslogout);
Lines 60-66 BEGIN { Link Here
60
    @ISA       = qw(Exporter);
61
    @ISA       = qw(Exporter);
61
    @EXPORT    = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions);
62
    @EXPORT    = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions);
62
    @EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &checkpw_internal &checkpw_hash
63
    @EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &checkpw_internal &checkpw_hash
63
      &get_all_subpermissions &get_user_subpermissions track_login_daily
64
      &get_all_subpermissions &get_user_subpermissions track_login_daily &in_ipset
64
    );
65
    );
65
    %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
66
    %EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] );
66
    $ldap      = C4::Context->config('useldapserver') || 0;
67
    $ldap      = C4::Context->config('useldapserver') || 0;
Lines 2106-2111 sub haspermission { Link Here
2106
    #FIXME - This fcn should return the failed permission so a suitable error msg can be delivered.
2107
    #FIXME - This fcn should return the failed permission so a suitable error msg can be delivered.
2107
}
2108
}
2108
2109
2110
=head2 in_ipset
2111
2112
  $flags = ($ipset);
2113
2114
C<$ipset> A space separated string describing an IP set. Can include single IPs or ranges
2115
2116
Returns 1 if the remote address is in the provided ipset, or 0 otherwise.
2117
2118
=cut
2119
2120
sub in_ipset {
2121
 my ($ipset) = @_;
2122
 my @allowedipranges = split(' ', $ipset);
2123
 if (scalar @allowedipranges > 0) {
2124
    my @rangelist;
2125
    eval { @rangelist = Net::CIDR::range2cidr(@allowedipranges); }; return 0 if $@;
2126
    unless (Net::CIDR::cidrlookup($ENV{'REMOTE_ADDR'}, @rangelist)) {
2127
      return 0;
2128
    }
2129
 }
2130
 return 1;
2131
}
2132
2109
sub getborrowernumber {
2133
sub getborrowernumber {
2110
    my ($userid) = @_;
2134
    my ($userid) = @_;
2111
    my $userenv = C4::Context->userenv;
2135
    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 521-526 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
521
('SearchEngine','Zebra','Elasticsearch|Zebra','Search Engine','Choice'),
521
('SearchEngine','Zebra','Elasticsearch|Zebra','Search Engine','Choice'),
522
('SearchMyLibraryFirst','0',NULL,'If ON, OPAC searches return results limited by the user\'s library by default if they are logged in','YesNo'),
522
('SearchMyLibraryFirst','0',NULL,'If ON, OPAC searches return results limited by the user\'s library by default if they are logged in','YesNo'),
523
('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo'),
523
('SearchWithISBNVariations','0',NULL,'If enabled, search on all variations of the ISBN','YesNo'),
524
('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'),
524
('SelfCheckHelpMessage','','70|10','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','Textarea'),
525
('SelfCheckHelpMessage','','70|10','Enter HTML to include under the basic Web-based Self Checkout instructions on the Help page','Textarea'),
525
('SelfCheckInMainUserBlock','','70|10','Add a block of HTML that will display on the self check-in screen.','Textarea'),
526
('SelfCheckInMainUserBlock','','70|10','Add a block of HTML that will display on the self check-in screen.','Textarea'),
526
('SelfCheckInModule', 0, NULL, 'Enable the standalone self-checkin module.', 'YesNo'),
527
('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 979-984 Circulation: Link Here
979
                  yes: Show
979
                  yes: Show
980
                  no: "Don't show"
980
                  no: "Don't show"
981
            - "the print receipt popup dialog when self checkout is finished"
981
            - "the print receipt popup dialog when self checkout is finished"
982
        -
983
            - pref: SelfCheckAllowByIPRanges
984
              class: short
985
            - (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>.)
982
    Course Reserves:
986
    Course Reserves:
983
        -
987
        -
984
            - pref: UseCourseReserves
988
            - 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 59-65 unless (C4::Context->preference('WebBasedSelfCheck')) { Link Here
59
    exit;
59
    exit;
60
}
60
}
61
61
62
if (C4::Context->preference('AutoSelfCheckAllowed')) 
62
unless ( in_ipset(C4::Context->preference('SelfCheckAllowByIPRanges')) ) {
63
    # redirect to OPAC home if self-checkout not permitted from current IP
64
    print $query->redirect("/cgi-bin/koha/opac-main.pl");
65
    exit;
66
}
67
68
if (C4::Context->preference('AutoSelfCheckAllowed'))
63
{
69
{
64
    my $AutoSelfCheckID = C4::Context->preference('AutoSelfCheckID');
70
    my $AutoSelfCheckID = C4::Context->preference('AutoSelfCheckID');
65
    my $AutoSelfCheckPass = C4::Context->preference('AutoSelfCheckPass');
71
    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