Lines 1209-1216
sub checkauth {
Link Here
|
1209 |
|
1209 |
|
1210 |
# we have to check they are coming from the right ip range |
1210 |
# we have to check they are coming from the right ip range |
1211 |
my $domain = $branches->{$branchcode}->{'branchip'}; |
1211 |
my $domain = $branches->{$branchcode}->{'branchip'}; |
1212 |
$domain =~ s|\.\*||g; |
1212 |
if ( ! in_iprange($domain) ) { |
1213 |
if ( $ip !~ /^$domain/ ) { |
|
|
1214 |
$loggedin = 0; |
1213 |
$loggedin = 0; |
1215 |
$cookie = $query->cookie( |
1214 |
$cookie = $query->cookie( |
1216 |
-name => 'CGISESSID', |
1215 |
-name => 'CGISESSID', |
Lines 1226-1232
sub checkauth {
Link Here
|
1226 |
|
1225 |
|
1227 |
# now we work with the treatment of ip |
1226 |
# now we work with the treatment of ip |
1228 |
my $domain = $branches->{$br}->{'branchip'}; |
1227 |
my $domain = $branches->{$br}->{'branchip'}; |
1229 |
if ( $domain && $ip =~ /^$domain/ ) { |
1228 |
if ( in_iprange($domain) ) { |
1230 |
$branchcode = $branches->{$br}->{'branchcode'}; |
1229 |
$branchcode = $branches->{$br}->{'branchcode'}; |
1231 |
|
1230 |
|
1232 |
# new op dev : add the branchname to the cookie |
1231 |
# new op dev : add the branchname to the cookie |
Lines 1682-1688
sub check_api_auth {
Link Here
|
1682 |
|
1681 |
|
1683 |
# now we work with the treatment of ip |
1682 |
# now we work with the treatment of ip |
1684 |
my $domain = $branches->{$br}->{'branchip'}; |
1683 |
my $domain = $branches->{$br}->{'branchip'}; |
1685 |
if ( $domain && $ip =~ /^$domain/ ) { |
1684 |
if ( in_iprange($domain) ) { |
1686 |
$branchcode = $branches->{$br}->{'branchcode'}; |
1685 |
$branchcode = $branches->{$br}->{'branchcode'}; |
1687 |
|
1686 |
|
1688 |
# new op dev : add the branchname to the cookie |
1687 |
# new op dev : add the branchname to the cookie |
Lines 2249-2257
Returns 1 if the remote address is in the provided iprange, or 0 otherwise.
Link Here
|
2249 |
|
2248 |
|
2250 |
sub in_iprange { |
2249 |
sub in_iprange { |
2251 |
my ($iprange) = @_; |
2250 |
my ($iprange) = @_; |
2252 |
my $result = 1; |
2251 |
my $result = 0; |
|
|
2252 |
# FIXME remove '*' for backwards compatibility in branchip settings |
2253 |
$iprange =~ s|\*||g; |
2253 |
my @allowedipranges = $iprange ? split(' ', $iprange) : (); |
2254 |
my @allowedipranges = $iprange ? split(' ', $iprange) : (); |
2254 |
if (scalar @allowedipranges > 0) { |
2255 |
if (@allowedipranges) { |
2255 |
my @rangelist; |
2256 |
my @rangelist; |
2256 |
eval { @rangelist = Net::CIDR::range2cidr(@allowedipranges); }; return 0 if $@; |
2257 |
eval { @rangelist = Net::CIDR::range2cidr(@allowedipranges); }; return 0 if $@; |
2257 |
eval { $result = Net::CIDR::cidrlookup($ENV{'REMOTE_ADDR'}, @rangelist) } || ( $ENV{DEBUG} && warn 'cidrlookup failed for ' . join(' ',@rangelist) ); |
2258 |
eval { $result = Net::CIDR::cidrlookup($ENV{'REMOTE_ADDR'}, @rangelist) } || ( $ENV{DEBUG} && warn 'cidrlookup failed for ' . join(' ',@rangelist) ); |