From 836add81c035aabc6673ade9d5f989fc0d3726c8 Mon Sep 17 00:00:00 2001 From: Christophe Maudoux Date: Sun, 27 Oct 2019 17:17:58 +0100 Subject: [PATCH] Parse conf (#1988) --- .../lib/Lemonldap/NG/Common/Conf/RESTServer.pm | 4 +++- lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/RESTServer.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/RESTServer.pm index bc12b02ee..d181fe181 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/RESTServer.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/RESTServer.pm @@ -195,12 +195,14 @@ sub virtualHosts { type => 'keyText', }; - # If rule contains a comment, split it + # If rule contains a comment or an AuthLevel, split them if ( $query eq 'locationRules' ) { $res->{comment} = ''; + $res->{level} = ''; if ( $r =~ s/\(\?#(.*?)\)// ) { $res->{title} = $res->{comment} = $1; } + $res->{level} = $1 if ( $r =~ s/\(\?#AuthnLevel=(-?\d+)\)// ); $res->{re} = $r; $res->{type} = 'rule'; } diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm index 425764a9e..96aaec34f 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Parser.pm @@ -264,8 +264,9 @@ sub _scanNodes { hdebug(' locationRules'); my $k = $leaf->{comment} - ? "(?#$leaf->{comment}&AuthnLevel=$leaf->{level})$leaf->{re}" - : "(?#&AuthnLevel=$leaf->{level})$leaf->{re}"; + ? "(?#$leaf->{comment})$leaf->{re}" + : $leaf->{re}; + $k .= "(?#AuthnLevel=$leaf->{level})" if $leaf->{level}; $self->set( $target, $key, $k, $leaf->{data} ); } else {