Bug 36867: (follow-up) Don't check IP if ILS-DI disabled
When ILS-DI is disabled we still expect to return the correct service name/section in the
xml, but just indicate that it is disabled.
We should skip the check for authorized IPs in this case, as the IP only matters when service is enabled
Signed-off-by: wainuiwitikapark <wainuiwitikapark@catalyst.net.nz>
(cherry picked from commit fd6d58bb4b)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
746f2ead15
commit
7eb4921f02
|
|
@ -159,36 +159,38 @@ my $out;
|
|||
unless ( C4::Context->preference('ILS-DI') ) {
|
||||
$out->{'code'} = "NotAllowed";
|
||||
$out->{'message'} = "ILS-DI is disabled.";
|
||||
}
|
||||
|
||||
# If the remote address is not allowed, redirect to 403
|
||||
my @AuthorizedIPs = split( /,/, C4::Context->preference('ILS-DI:AuthorizedIPs') );
|
||||
if (@AuthorizedIPs) { # If no filter set, allow access to everybody
|
||||
my $authorized = 0;
|
||||
foreach my $ip (@AuthorizedIPs) {
|
||||
my $netmask = Net::Netmask->new2($ip);
|
||||
if ( $netmask && $netmask->match( $ENV{REMOTE_ADDR} ) ) {
|
||||
$authorized = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
unless ($authorized) {
|
||||
$out->{'code'} = "NotAllowed";
|
||||
$out->{'message'} = "Unauthorized IP address: $ENV{REMOTE_ADDR}.";
|
||||
}
|
||||
} else {
|
||||
$out->{'code'} = "NotAllowed";
|
||||
$out->{'message'} = "Unauthorized IP address: $ENV{REMOTE_ADDR}.";
|
||||
|
||||
print XMLout(
|
||||
$out,
|
||||
noattr => 1,
|
||||
nosort => 1,
|
||||
xmldecl => '<?xml version="1.0" encoding="UTF-8" ?>',
|
||||
RootName => "ilsdi",
|
||||
SuppressEmpty => 1
|
||||
);
|
||||
exit 0;
|
||||
# If the remote address is not allowed, redirect to 403
|
||||
my @AuthorizedIPs = split( /,/, C4::Context->preference('ILS-DI:AuthorizedIPs') );
|
||||
if (@AuthorizedIPs) { # If no filter set, allow access to everybody
|
||||
my $authorized = 0;
|
||||
foreach my $ip (@AuthorizedIPs) {
|
||||
my $netmask = Net::Netmask->new2($ip);
|
||||
if ( $netmask && $netmask->match( $ENV{REMOTE_ADDR} ) ) {
|
||||
$authorized = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
unless ($authorized) {
|
||||
$out->{'code'} = "NotAllowed";
|
||||
$out->{'message'} = "Unauthorized IP address: $ENV{REMOTE_ADDR}.";
|
||||
}
|
||||
} else {
|
||||
$out->{'code'} = "NotAllowed";
|
||||
$out->{'message'} = "Unauthorized IP address: $ENV{REMOTE_ADDR}.";
|
||||
|
||||
print XMLout(
|
||||
$out,
|
||||
noattr => 1,
|
||||
nosort => 1,
|
||||
xmldecl => '<?xml version="1.0" encoding="UTF-8" ?>',
|
||||
RootName => "ilsdi",
|
||||
SuppressEmpty => 1
|
||||
);
|
||||
exit 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
my $service = $cgi->param('service') || "ilsdi";
|
||||
|
|
|
|||
Loading…
Reference in New Issue