Remove a test for undefined vhost in grant function (#362)
This commit is contained in:
parent
520f02a181
commit
f039322003
@ -7,7 +7,7 @@ package Lemonldap::NG::Portal::_LibAccess;
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
our $VERSION = '1.0.2';
|
our $VERSION = '1.1.2';
|
||||||
|
|
||||||
# Global variables
|
# Global variables
|
||||||
our ( $defaultCondition, $locationCondition, $locationRegexp, $cfgNum ) =
|
our ( $defaultCondition, $locationCondition, $locationRegexp, $cfgNum ) =
|
||||||
@ -29,21 +29,32 @@ BEGIN {
|
|||||||
# @return True if granted
|
# @return True if granted
|
||||||
sub _grant {
|
sub _grant {
|
||||||
my ( $self, $uri ) = splice @_;
|
my ( $self, $uri ) = splice @_;
|
||||||
|
$self->lmLog( "Evaluate access right on $uri", 'debug' );
|
||||||
$uri =~ m{(\w+)://([^/:]+)(:\d+)?(/.*)?$} or return 0;
|
$uri =~ m{(\w+)://([^/:]+)(:\d+)?(/.*)?$} or return 0;
|
||||||
my ( $protocol, $vhost, $port, $path );
|
my ( $protocol, $vhost, $port, $path );
|
||||||
( $protocol, $vhost, $port, $path ) = ( $1, $2, $3, $4 );
|
( $protocol, $vhost, $port, $path ) = ( $1, $2, $3, $4 );
|
||||||
$path ||= '/';
|
$path ||= '/';
|
||||||
|
$self->lmLog( "Evaluation for vhost $vhost and path $path", 'debug' );
|
||||||
$self->_compileRules()
|
$self->_compileRules()
|
||||||
if ( $cfgNum != $self->{cfgNum} );
|
if ( $cfgNum != $self->{cfgNum} );
|
||||||
return -1 unless ( defined( $defaultCondition->{$vhost} ) );
|
|
||||||
|
|
||||||
if ( defined $locationRegexp->{$vhost} ) { # Not just a default rule
|
if ( defined $locationRegexp->{$vhost} ) { # Not just a default rule
|
||||||
|
$self->lmLog( "Applying access rule from $vhost", 'debug' );
|
||||||
for ( my $i = 0 ; $i < @{ $locationRegexp->{$vhost} } ; $i++ ) {
|
for ( my $i = 0 ; $i < @{ $locationRegexp->{$vhost} } ; $i++ ) {
|
||||||
if ( $path =~ $locationRegexp->{$vhost}->[$i] ) {
|
if ( $path =~ $locationRegexp->{$vhost}->[$i] ) {
|
||||||
|
$self->lmLog(
|
||||||
|
"Applying access rule "
|
||||||
|
. $locationCondition->{$vhost}->[$i]
|
||||||
|
. " for path $path",
|
||||||
|
'debug'
|
||||||
|
);
|
||||||
return &{ $locationCondition->{$vhost}->[$i] }($self);
|
return &{ $locationCondition->{$vhost}->[$i] }($self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$self->lmLog( "Applying default access rule from $vhost", 'debug' );
|
||||||
|
}
|
||||||
unless ( $defaultCondition->{$vhost} ) {
|
unless ( $defaultCondition->{$vhost} ) {
|
||||||
$self->lmLog(
|
$self->lmLog(
|
||||||
"Application $uri did not match any configured virtual host",
|
"Application $uri did not match any configured virtual host",
|
||||||
@ -61,6 +72,7 @@ sub _compileRules {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
foreach my $vhost ( keys %{ $self->{locationRules} } ) {
|
foreach my $vhost ( keys %{ $self->{locationRules} } ) {
|
||||||
my $i = 0;
|
my $i = 0;
|
||||||
|
$self->lmLog( "Compiling rules for $vhost", 'debug' );
|
||||||
foreach ( keys %{ $self->{locationRules}->{$vhost} } ) {
|
foreach ( keys %{ $self->{locationRules}->{$vhost} } ) {
|
||||||
if ( $_ eq 'default' ) {
|
if ( $_ eq 'default' ) {
|
||||||
$defaultCondition->{$vhost} =
|
$defaultCondition->{$vhost} =
|
||||||
|
Loading…
Reference in New Issue
Block a user