Fix vhost wildcard order (#2188)

Moo
Xavier Guimard 5 years ago
parent 7d35953668
commit f2e892a44d
  1. 8
      lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/Reload.pm
  2. 4
      lemonldap-ng-handler/t/60-Lemonldap-NG-Handler-PSGI.t
  3. 3
      lemonldap-ng-handler/t/lmConf-1.json

@ -337,10 +337,10 @@ sub locationRulesInit {
@{ $class->tsv->{vhostReg} } = sort {
my $av = $a->[1];
my $bv = $b->[1];
return -1 if $av =~ /^*/ and $bv !~ /^*/;
return 1 if $bv =~ /^*/ and $av !~ /^*/;
return length($a) <=> length($b);
} @{ $class->tsv->{vhostReg} };
return 1 if $av =~ /^\*/ and $bv !~ /^\*/;
return -1 if $bv =~ /^\*/ and $av !~ /^\*/;
return length($bv) <=> length($av);
} @{ $class->tsv->{vhostReg} } if @{ $class->tsv->{vhostReg} };
push @{ $class->tsv->{vhostReg} }, @lastReg if @lastReg;
return 1;
}

@ -195,6 +195,10 @@ ok($res = $client->_get( '/orgdeny', undef, 'afoo.example.org', "lemonldap=$sess
ok( $res->[0] == 200, ' Code is 200' ) or explain( $res, 200 );
count(2);
ok($res = $client->_get( '/orgdeny', undef, 'abfoo.example.org', "lemonldap=$sessionId" ), 'Reject "abfoo.example.org/orgdeny"');
ok( $res->[0] == 302, ' Code is 302' ) or explain( $res, 302 );
count(2);
ok($res = $client->_get( '/', undef, 'test-foo.example.fr', "lemonldap=$sessionId" ), 'Accept "test*.example.fr"');
ok( $res->[0] == 200, ' Code is 200' ) or explain( $res, 200 );
count(2);

@ -65,6 +65,9 @@
"a*.example.org": {
"default": "accept"
},
"ab*.example.org": {
"default": "deny"
},
"test*.example.fr": {
"default": "accept"
}

Loading…
Cancel
Save