Manager part of issuerDBGet seems to be finished (#1025)
This commit is contained in:
parent
11137f0c8a
commit
5e080f90c9
|
@ -35,6 +35,7 @@ my $ignoreKeys;
|
|||
my $mainTree;
|
||||
my @sessionTypes;
|
||||
my @simpleHashKeys;
|
||||
my @doubleHashKeys;
|
||||
my $authParameters;
|
||||
my $issuerParameters;
|
||||
my $samlServiceParameters;
|
||||
|
@ -153,7 +154,7 @@ sub run {
|
|||
open F, ">", $self->managerConstantsFile or die($!);
|
||||
my $exportedVars =
|
||||
'$'
|
||||
. join( 'Keys $', 'simpleHash', 'specialNode', sort keys %cnodesRe )
|
||||
. join( 'Keys $', 'simpleHash', 'doubleHash', 'specialNode', sort keys %cnodesRe )
|
||||
. 'Keys $specialNodeHash @sessionTypes $authParameters $issuerParameters $samlServiceParameters $oidcServiceParameters';
|
||||
print F <<EOF;
|
||||
# This file is generated by $module. Don't modify it by hand
|
||||
|
@ -184,6 +185,11 @@ EOF
|
|||
# Reinitialize $attributes
|
||||
$attributes = Lemonldap::NG::Manager::Build::Attributes::attributes();
|
||||
|
||||
$ra = Regexp::Assemble->new;
|
||||
foreach (@doubleHashKeys) {
|
||||
$ra->add($_);
|
||||
}
|
||||
print F "our \$doubleHashKeys = '" . $ra->as_string . "';\n";
|
||||
$ra = Regexp::Assemble->new;
|
||||
foreach (@simpleHashKeys) {
|
||||
$ra->add($_);
|
||||
|
@ -529,6 +535,9 @@ sub scanTree {
|
|||
push @simpleHashKeys, $leaf;
|
||||
}
|
||||
}
|
||||
elsif ( $attr->{type} eq 'doubleHash' and $leaf !~ $reIgnoreKeys ) {
|
||||
push @doubleHashKeys, $leaf;
|
||||
}
|
||||
else {
|
||||
if ( $prefix and !$jleaf->{get} ) {
|
||||
$jleaf->{get} = $prefix . $jleaf->{title};
|
||||
|
|
|
@ -19,6 +19,8 @@ use feature 'state';
|
|||
|
||||
extends 'Lemonldap::NG::Manager::Lib';
|
||||
|
||||
our $VERSION = '2.0.0';
|
||||
|
||||
#############################
|
||||
# I. INITIALIZATION METHODS #
|
||||
#############################
|
||||
|
@ -738,6 +740,19 @@ sub getKey {
|
|||
}
|
||||
return $self->sendJSONresponse( $req, \@res );
|
||||
}
|
||||
elsif ( $key =~ qr/^$doubleHashKeys$/o ) {
|
||||
my @res;
|
||||
if ( defined $value ) {
|
||||
foreach my $host ( sort keys %$value ) {
|
||||
my @tmp;
|
||||
foreach my $k ( sort keys %{ $value->{$host} } ) {
|
||||
push @tmp, { k => $k, v => $value->{$host}->{$k} };
|
||||
}
|
||||
push @res, { k => $host, h => \@tmp };
|
||||
}
|
||||
}
|
||||
return $self->sendJSONresponse( $req, { value => \@res } );
|
||||
}
|
||||
|
||||
# When scalar
|
||||
return $self->sendError( $req, "Key $key is not a hash", 400 )
|
||||
|
|
|
@ -24,6 +24,8 @@ use Mouse;
|
|||
use Lemonldap::NG::Manager::Constants;
|
||||
use Lemonldap::NG::Manager::Attributes;
|
||||
|
||||
our $VERSION = '2.0.0';
|
||||
|
||||
# High debugging for developpers, set this to 1
|
||||
use constant HIGHDEBUG => 0;
|
||||
|
||||
|
@ -626,7 +628,7 @@ sub _scanNodes {
|
|||
####################
|
||||
# Other hash nodes #
|
||||
####################
|
||||
elsif ( $leaf->{title} =~ $simpleHashKeys
|
||||
elsif ( $leaf->{title} =~ /^$simpleHashKeys$/o
|
||||
and not $leaf->{title} eq 'applicationList' )
|
||||
{
|
||||
hdebug( $leaf->{title} );
|
||||
|
@ -681,6 +683,75 @@ sub _scanNodes {
|
|||
next;
|
||||
}
|
||||
|
||||
# Double hash nodes
|
||||
elsif ( $leaf->{title} =~ /^$doubleHashKeys$/ ) {
|
||||
hdebug( $leaf->{title} );
|
||||
my @oldHosts = (
|
||||
ref( $self->refConf->{$name} )
|
||||
? ( keys %{ $self->refConf->{$name} } )
|
||||
: ()
|
||||
);
|
||||
$self->newConf->{$name} = {};
|
||||
if ( ref( $leaf->{data} ) ne 'ARRAY' ) {
|
||||
$self->lmLog( "Double hash doesn't push an array, aborting",
|
||||
'error' );
|
||||
return 0;
|
||||
}
|
||||
foreach my $getHost ( @{ $leaf->{data} } ) {
|
||||
my $change = 0;
|
||||
my @oldKeys;
|
||||
my $host = $getHost->{k};
|
||||
hdebug(" looking at host: $host");
|
||||
$self->newConf->{$name}->{$host} = {};
|
||||
unless ( defined $self->refConf->{$name}->{$host} ) {
|
||||
$self->confChanged(1);
|
||||
$change++;
|
||||
push @{ $self->changes }, { key => $name, new => $host };
|
||||
hdebug(" $host is new");
|
||||
}
|
||||
else {
|
||||
@oldHosts = grep { $_ ne $host } @oldHosts;
|
||||
@oldKeys = keys %{ $self->refConf->{$name}->{$host} };
|
||||
}
|
||||
foreach my $prm ( @{ $getHost->{h} } ) {
|
||||
$self->newConf->{$name}->{$host}->{ $prm->{k} } = $prm->{v};
|
||||
if (
|
||||
!$change
|
||||
and (
|
||||
not defined(
|
||||
$self->refConf->{$name}->{$host}->{ $prm->{k} }
|
||||
)
|
||||
or $self->newConf->{$name}->{$host}->{ $prm->{k} }
|
||||
ne $self->refConf->{$name}->{$host}->{ $prm->{k} }
|
||||
)
|
||||
)
|
||||
{
|
||||
$self->confChanged(1);
|
||||
hdebug(" key $prm->{k} has been changed");
|
||||
push @{ $self->changes },
|
||||
{ key => "$name/$host", new => $prm->{k} };
|
||||
}
|
||||
elsif ( !$change ) {
|
||||
@oldKeys = grep { $_ ne $prm->{k} } @oldKeys;
|
||||
}
|
||||
}
|
||||
if (@oldKeys) {
|
||||
$self->confChanged(1);
|
||||
hdebug( " old keys: " . join( ' ', @oldKeys ) );
|
||||
push @{ $self->changes },
|
||||
{ key => "$name/$host", old => $_ }
|
||||
foreach (@oldKeys);
|
||||
}
|
||||
}
|
||||
if (@oldHosts) {
|
||||
$self->confChanged(1);
|
||||
hdebug( " old hosts " . join( ' ', @oldHosts ) );
|
||||
push @{ $self->changes }, { key => "$name", old => $_ }
|
||||
foreach (@oldHosts);
|
||||
}
|
||||
next;
|
||||
}
|
||||
|
||||
###############
|
||||
# Other nodes #
|
||||
###############
|
||||
|
@ -839,7 +910,7 @@ sub _unitTest {
|
|||
}
|
||||
|
||||
# Hash parameters
|
||||
if ( $key =~ $simpleHashKeys ) {
|
||||
if ( $key =~ /^$simpleHashKeys$/o ) {
|
||||
$conf->{$key} //= {};
|
||||
unless ( ref $conf->{$key} eq 'HASH' ) {
|
||||
push @{ $self->errors },
|
||||
|
@ -852,7 +923,9 @@ sub _unitTest {
|
|||
|
||||
#TODO
|
||||
}
|
||||
if ( $key =~ $simpleHashKeys or $attr->{type} =~ /Container$/ ) {
|
||||
if ( $key =~ /^$simpleHashKeys$/o
|
||||
or $attr->{type} =~ /Container$/ )
|
||||
{
|
||||
my $keyMsg = $attr->{keyMsgFail} // $type->{keyMsgFail};
|
||||
my $msg = $attr->{msgFail} // $type->{msgFail};
|
||||
$res = 0
|
||||
|
|
|
@ -7,7 +7,7 @@ use base qw(Exporter);
|
|||
|
||||
our $VERSION = '2.0.0';
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [qw($simpleHashKeys $specialNodeKeys $oidcOPMetaDataNodeKeys $oidcRPMetaDataNodeKeys $samlIDPMetaDataNodeKeys $samlSPMetaDataNodeKeys $virtualHostKeys $specialNodeHash @sessionTypes $authParameters $issuerParameters $samlServiceParameters $oidcServiceParameters)] );
|
||||
our %EXPORT_TAGS = ( 'all' => [qw($simpleHashKeys $doubleHashKeys $specialNodeKeys $oidcOPMetaDataNodeKeys $oidcRPMetaDataNodeKeys $samlIDPMetaDataNodeKeys $samlSPMetaDataNodeKeys $virtualHostKeys $specialNodeHash @sessionTypes $authParameters $issuerParameters $samlServiceParameters $oidcServiceParameters)] );
|
||||
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
||||
our @EXPORT = ( @{ $EXPORT_TAGS{'all'} } );
|
||||
|
||||
|
@ -21,6 +21,7 @@ our $specialNodeHash = {
|
|||
|
||||
our @sessionTypes = ( 'captcha', 'remoteGlobal', 'cas', 'global', 'localSession', 'persistent', 'saml', 'oidc' );
|
||||
|
||||
our $doubleHashKeys = 'issuerDBGetParameters';
|
||||
our $simpleHashKeys = '(?:(?:g(?:r(?:antSessionRule|oup)|lobalStorageOption|oogleExportedVar)|l(?:o(?:calSessionStorageOption|goutService)|dapExportedVar)|ca(?:s(?:StorageOption|Attribute)|ptchaStorageOption)|(?:(?:d(?:emo|bi)|facebook|webID)E|e)xportedVar|p(?:ersistentStorageOption|ortalSkinRule)|re(?:moteGlobalStorageOption|loadUrl)|notificationStorageOption|CASproxiedService|macro)s|o(?:idcS(?:erviceMetaDataAuthnContext|torageOptions)|penIdExportedVars)|s(?:(?:amlStorageOption|laveExportedVar)s|essionDataToRemember)|a(?:uthChoiceModules|pplicationList))';
|
||||
our $specialNodeKeys = '(?:(?:saml(?:ID|S)|oidc[OR])PMetaDataNode|virtualHost)s';
|
||||
our $oidcOPMetaDataNodeKeys = 'oidcOPMetaData(?:Options(?:C(?:lient(?:Secret|ID)|heckJWTSignature|onfigurationURI)|TokenEndpointAuthMethod|(?:JWKSTimeou|Promp)t|I(?:DTokenMaxAge|con)|U(?:iLocales|seNonce)|Display(?:Name)?|(?:MaxAg|Scop)e|AcrValues)|ExportedVars|J(?:SON|WKS))';
|
||||
|
|
|
@ -34,7 +34,6 @@ Special container to show hash in hash
|
|||
[{
|
||||
'title': 'newHost',
|
||||
'action': function(cn,scope){
|
||||
console.log(cn);
|
||||
if(!cn.data) cn.data=[];
|
||||
cn.data.push({"k":"newHost",h:[{"k":"key","v":"uid"}]});
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user