Modify WebGUI IP fields to use CIDR format instead of a regular expression.
Multiple IPs are separated by commas, whitespace is ignored. In groups, that affects the ipFilter field, User::isInGroup. In settings, that affects Settings::debugIp and Session::ErrorHandler::canShowDebug. Fixed a bug in WebGUI::Utility::isInSubnet where Net::Subnets->check needs a scalar. Modified t/User.t to use addresses in CIDR format.
This commit is contained in:
parent
c6bc09f79c
commit
cd6759f311
7 changed files with 55 additions and 26 deletions
|
|
@ -87,14 +87,10 @@ sub canShowDebug {
|
|||
return 0 unless ($self->session->setting->get("showDebug"));
|
||||
return 0 unless ($self->session->http->getMimeType eq "text/html");
|
||||
return 1 if ($self->session->setting->get("debugIp") eq "");
|
||||
my @ips = split(" ",$self->session->setting->get("debugIp"));
|
||||
my $ok = 0;
|
||||
foreach my $ip (@ips) {
|
||||
if ($self->session->env->get("REMOTE_ADDR") =~ /^$ip/) {
|
||||
$ok = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
my $ips = $self->session->setting->get("debugIp");
|
||||
$ips =~ s/\s+//g;
|
||||
my @ips = split(",", $ips);
|
||||
my $ok = WebGUI::Utility::isInSubnet($self->session->env->get("REMOTE_ADDR"), [ @ips] );
|
||||
return $ok;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -258,16 +258,10 @@ sub isInGroup {
|
|||
### Check IP Address
|
||||
if ($group->get("ipFilter")) {
|
||||
my $ipFilter = $group->get("ipFilter");
|
||||
$ipFilter =~ s/\s//g;
|
||||
$ipFilter =~ s/\./\\\./g;
|
||||
my @ips = split(";",$ipFilter);
|
||||
foreach my $ip (@ips) {
|
||||
if ($self->session->env->get("REMOTE_ADDR") =~ /^$ip/) {
|
||||
$isInGroup->{$uid}{$gid} = 1;
|
||||
$self->session->stow->set("isInGroup",$isInGroup);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
$ipFilter =~ s/\s+//g;
|
||||
my @ips = split(",",$ipFilter);
|
||||
my $ipMatch = WebGUI::Utility::isInSubnet($self->session->env->get("REMOTE_ADDR"), [ @ips ]);
|
||||
return 1 if $ipMatch;
|
||||
}
|
||||
return 0 if ($uid eq '1'); #Visitor is in no other groups
|
||||
return 1 if ($uid eq '3'); #Admin is in every group
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ sub isInSubnet {
|
|||
}
|
||||
my $net = Net::Subnets->new;
|
||||
$net->subnets($subnets);
|
||||
if ($net->check($ip)) {
|
||||
if ($net->check(\$ip)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ our $I18N = {
|
|||
},
|
||||
|
||||
'debug ip description' => {
|
||||
message => q|This will limit debugging output to a specific IP address or IP range. To limit the output to anyone in a subnet of 10.0.0.0/24 you'd simply enter 10.0.0. |,
|
||||
lastUpdated => 0
|
||||
message => q|This will limit debugging output to a specific IP address or IP range. Enter the subnet that you want to be able to view debug output in CIDR format. For example: 10.0.0.0/24. Multiple CIDR addresses may be entered, separated by commas.|,
|
||||
lastUpdated => 1139948380
|
||||
},
|
||||
|
||||
'debug ip' => {
|
||||
|
|
@ -1760,11 +1760,11 @@ As with any delete operation, you are prompted to be sure you wish to proceed wi
|
|||
},
|
||||
|
||||
'857 description' => {
|
||||
message => q|Specify an IP address or an IP mask to match. If the user's IP address matches, they'll automatically be included in this group. An IP mask is simply the IP address minus an octet or two. You may also specify multiple IP masks separated by semicolons.
|
||||
message => q|Specify IP addresses in CIDR format. Multiple addresses can be entered if they are separated by commas. Spaces, tabs and carriage returns and newlines will be ignored.
|
||||
<p>
|
||||
<i>IP Mask Example:</i> 10.;192.168.;101.42.200.142
|
||||
<i>IP Mask Example:</i> 10.0.0.32/27, 192.168.0.1/30
|
||||
<p>|,
|
||||
lastUpdated => 1120448672,
|
||||
lastUpdated => 1139955354,
|
||||
},
|
||||
|
||||
'945 description' => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue