2015-12-27 23:14:43 +01:00
|
|
|
package Lemonldap::NG::Manager::Build;
|
|
|
|
|
|
|
|
use strict;
|
2016-01-07 13:34:34 +01:00
|
|
|
use utf8;
|
2015-12-27 23:14:43 +01:00
|
|
|
use Mouse;
|
|
|
|
use Lemonldap::NG::Manager::Build::Attributes;
|
|
|
|
use Lemonldap::NG::Manager::Build::Tree;
|
|
|
|
use Lemonldap::NG::Manager::Build::CTrees;
|
2019-09-17 20:17:57 +02:00
|
|
|
use Lemonldap::NG::Manager::Build::PortalConstants;
|
2016-01-05 22:33:49 +01:00
|
|
|
use Lemonldap::NG::Manager::Conf::Zero;
|
2015-12-27 23:14:43 +01:00
|
|
|
use Data::Dumper;
|
|
|
|
use Regexp::Assemble;
|
2016-01-13 20:47:56 +01:00
|
|
|
use JSON;
|
2015-12-27 23:14:43 +01:00
|
|
|
use Getopt::Std;
|
|
|
|
use IO::String;
|
|
|
|
|
2019-09-17 20:17:57 +02:00
|
|
|
has structFile => ( isa => 'Str', is => 'ro', required => 1 );
|
|
|
|
has confTreeFile => ( isa => 'Str', is => 'ro', required => 1 );
|
|
|
|
has managerConstantsFile => ( isa => 'Str', is => 'ro', required => 1 );
|
|
|
|
has managerAttributesFile => ( isa => 'Str', is => 'ro', required => 1 );
|
|
|
|
has defaultValuesFile => ( isa => 'Str', is => 'ro', required => 1 );
|
|
|
|
has confConstantsFile => ( isa => 'Str', is => 'ro', required => 1 );
|
|
|
|
has firstLmConfFile => ( isa => 'Str', is => 'ro', required => 1 );
|
|
|
|
has reverseTreeFile => ( isa => 'Str', is => 'ro', required => 1 );
|
|
|
|
has portalConstantsFile => ( isa => 'Str', is => 'ro', required => 1 );
|
|
|
|
has handlerStatusConstantsFile => ( isa => 'Str', is => 'ro', required => 1 );
|
2015-12-27 23:14:43 +01:00
|
|
|
|
2016-03-09 07:06:45 +01:00
|
|
|
my @managerAttrKeys = qw(keyTest keyMsgFail select type test msgFail default);
|
2015-12-27 23:14:43 +01:00
|
|
|
my $format = 'Creating %-69s: ';
|
|
|
|
my $reIgnoreKeys = qr/^$/;
|
2015-12-28 06:29:34 +01:00
|
|
|
my $module = __PACKAGE__;
|
2015-12-27 23:14:43 +01:00
|
|
|
|
|
|
|
my @angularScopeVars;
|
2019-04-15 11:44:11 +02:00
|
|
|
my @bool;
|
2021-02-18 22:08:47 +01:00
|
|
|
my @arrayParam;
|
2015-12-27 23:14:43 +01:00
|
|
|
my @cnodesKeys;
|
|
|
|
my %cnodesRe;
|
|
|
|
my @ignoreKeys;
|
|
|
|
my $ignoreKeys;
|
|
|
|
my $mainTree;
|
|
|
|
my @sessionTypes;
|
|
|
|
my @simpleHashKeys;
|
2016-06-05 08:55:28 +02:00
|
|
|
my @doubleHashKeys;
|
2016-03-19 09:23:55 +01:00
|
|
|
my $authParameters;
|
|
|
|
my $issuerParameters;
|
|
|
|
my $samlServiceParameters;
|
|
|
|
my $oidcServiceParameters;
|
2017-04-12 18:45:55 +02:00
|
|
|
my $casServiceParameters = [];
|
2016-12-03 19:26:56 +01:00
|
|
|
my $defaultValues;
|
2015-12-27 23:14:43 +01:00
|
|
|
|
|
|
|
my $attributes = Lemonldap::NG::Manager::Build::Attributes::attributes();
|
|
|
|
my $jsonEnc = JSON->new()->allow_nonref;
|
|
|
|
$jsonEnc->canonical(1);
|
|
|
|
|
|
|
|
$Data::Dumper::Sortkeys = sub {
|
|
|
|
my ($hash) = @_;
|
|
|
|
return [
|
|
|
|
( defined $hash->{id} ? ('id') : () ),
|
|
|
|
( defined $hash->{title} ? ( 'title', ) : () ),
|
|
|
|
(
|
|
|
|
grep { /^(?:id|title)$/ ? 0 : 1 }
|
|
|
|
sort {
|
|
|
|
return 1
|
|
|
|
if ( $a =~ /node/ and $b !~ /node/ );
|
|
|
|
return -1 if ( $b =~ /node/ );
|
|
|
|
lc($a) cmp lc($b);
|
|
|
|
} keys %$hash
|
|
|
|
)
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2016-02-03 22:54:50 +01:00
|
|
|
$Data::Dumper::Deparse = 1;
|
|
|
|
$Data::Dumper::Deepcopy = 1;
|
2015-12-30 21:16:15 +01:00
|
|
|
|
2015-12-27 23:14:43 +01:00
|
|
|
sub run {
|
|
|
|
my $self = shift;
|
2015-12-28 06:29:34 +01:00
|
|
|
$self = $module->new(@_) unless ref $self;
|
2015-12-27 23:14:43 +01:00
|
|
|
|
|
|
|
# 1. confTree.js
|
|
|
|
printf STDERR $format, $self->confTreeFile;
|
|
|
|
$mainTree = Lemonldap::NG::Manager::Build::CTrees::cTrees();
|
|
|
|
|
2016-01-21 13:10:12 +01:00
|
|
|
my $script = 'function templates(tpl,key) {
|
2016-01-21 13:15:38 +01:00
|
|
|
var ind;
|
|
|
|
var scalarTemplate = function(r) {
|
|
|
|
return {
|
|
|
|
"id": tpl+"s/"+(ind++),
|
|
|
|
"title": r,
|
|
|
|
"get": tpl+"s/"+key+"/"+r
|
|
|
|
};
|
2016-01-21 13:10:12 +01:00
|
|
|
};
|
2016-01-21 13:15:38 +01:00
|
|
|
switch(tpl){
|
2016-01-20 08:59:35 +01:00
|
|
|
';
|
2015-12-27 23:14:43 +01:00
|
|
|
|
2018-04-03 10:23:31 +02:00
|
|
|
my $reverseScanResult =
|
|
|
|
$self->reverseScan( Lemonldap::NG::Manager::Build::Tree::tree(), '', {} );
|
|
|
|
|
2015-12-27 23:14:43 +01:00
|
|
|
# To build confTree.js, each special node is scanned from
|
|
|
|
# Lemonldap::NG::Manager::Build::CTrees
|
|
|
|
foreach my $node ( sort keys %$mainTree ) {
|
|
|
|
@cnodesKeys = ();
|
|
|
|
my $jsonTree = [];
|
|
|
|
$self->scanTree( $mainTree->{$node}, $jsonTree, '__KEY__', '' );
|
2016-01-20 08:59:35 +01:00
|
|
|
$jsonEnc->pretty(1);
|
2015-12-27 23:14:43 +01:00
|
|
|
my $tmp = $jsonEnc->encode($jsonTree);
|
|
|
|
$tmp =~ s!"__KEY__!tpl+"s/"+key+"/"+"!mg;
|
|
|
|
$tmp =~ s/"(true|false)"/$1/sg;
|
|
|
|
$tmp =~ s/:\s*"(\d+)"\s*(["\}])/:$1$2/sg;
|
2016-01-21 13:10:12 +01:00
|
|
|
$script .= " case '$node':
|
|
|
|
return $tmp;
|
2016-01-20 08:59:35 +01:00
|
|
|
";
|
2015-12-27 23:14:43 +01:00
|
|
|
|
2018-07-05 22:56:16 +02:00
|
|
|
# Second step, Manager/Constants.pm file will contain data issued from
|
2015-12-27 23:14:43 +01:00
|
|
|
# this scan
|
|
|
|
my $ra = Regexp::Assemble->new;
|
|
|
|
|
|
|
|
# Build $oidcOPMetaDataNodeKeys, $samlSPMetaDataNodeKeys,...
|
|
|
|
foreach my $r (@cnodesKeys) {
|
|
|
|
$ra->add($r);
|
|
|
|
}
|
|
|
|
$cnodesRe{$node} = $ra->as_string;
|
|
|
|
|
|
|
|
push @ignoreKeys, $node;
|
|
|
|
}
|
2016-01-21 13:10:12 +01:00
|
|
|
$script .= " default:\n return [];\n }\n}";
|
2015-12-27 23:14:43 +01:00
|
|
|
open F, ">", $self->confTreeFile or die $!;
|
|
|
|
print F $script;
|
|
|
|
close F;
|
|
|
|
print STDERR "done\n";
|
|
|
|
my $ra = Regexp::Assemble->new;
|
|
|
|
foreach my $re (@ignoreKeys) {
|
|
|
|
$ra->add($re);
|
|
|
|
}
|
|
|
|
$ignoreKeys = $ra->as_string;
|
|
|
|
$reIgnoreKeys = $ra->re;
|
|
|
|
|
2016-12-03 19:26:56 +01:00
|
|
|
# Reinitialize $defaultValues
|
|
|
|
$defaultValues = {};
|
|
|
|
|
2015-12-27 23:14:43 +01:00
|
|
|
# 2. struct.json
|
|
|
|
printf STDERR $format, $self->structFile;
|
|
|
|
$mainTree = Lemonldap::NG::Manager::Build::Tree::tree();
|
|
|
|
my $jsonTree = [];
|
|
|
|
$self->scanTree( $mainTree, $jsonTree, '', '' );
|
2016-01-21 13:10:12 +01:00
|
|
|
$script = "\n\nfunction setScopeVars(scope) {\n";
|
2015-12-27 23:14:43 +01:00
|
|
|
foreach my $v (@angularScopeVars) {
|
2016-01-22 17:53:41 +01:00
|
|
|
$script .=
|
|
|
|
" scope.$v->[0] = scope$v->[1];\n scope.getKey(scope.$v->[0]);\n";
|
2015-12-27 23:14:43 +01:00
|
|
|
}
|
2016-01-21 13:10:12 +01:00
|
|
|
$script .= "}";
|
2015-12-27 23:14:43 +01:00
|
|
|
open F, ">>", $self->confTreeFile || die $!;
|
|
|
|
print F $script;
|
|
|
|
close F;
|
|
|
|
open F, ">", $self->structFile || die $!;
|
2016-01-20 08:59:35 +01:00
|
|
|
$jsonEnc->pretty(0);
|
2015-12-27 23:14:43 +01:00
|
|
|
my $tmp = $jsonEnc->encode($jsonTree);
|
|
|
|
$tmp =~ s/"(true|false)"/$1/sg;
|
|
|
|
$tmp =~ s/:\s*"(\d+)"\s*(["\}])/:$1$2/sg;
|
|
|
|
print F $tmp;
|
|
|
|
close F;
|
|
|
|
print STDERR "done\n";
|
|
|
|
$tmp = undef;
|
|
|
|
|
|
|
|
printf STDERR $format, $self->managerConstantsFile;
|
|
|
|
|
|
|
|
open F, ">", $self->managerConstantsFile or die($!);
|
2016-11-15 17:04:43 +01:00
|
|
|
my $exportedVars = '$'
|
|
|
|
. join( 'Keys $',
|
|
|
|
'simpleHash', 'doubleHash', 'specialNode', sort keys %cnodesRe )
|
2017-04-12 18:45:55 +02:00
|
|
|
. 'Keys $specialNodeHash $authParameters $issuerParameters $samlServiceParameters $oidcServiceParameters $casServiceParameters';
|
2015-12-27 23:14:43 +01:00
|
|
|
print F <<EOF;
|
2015-12-28 06:29:34 +01:00
|
|
|
# This file is generated by $module. Don't modify it by hand
|
2017-01-10 22:43:37 +01:00
|
|
|
package Lemonldap::NG::Common::Conf::ReConstants;
|
2015-12-27 23:14:43 +01:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Exporter 'import';
|
|
|
|
use base qw(Exporter);
|
|
|
|
|
|
|
|
our \$VERSION = '$Lemonldap::NG::Manager::Build::Attributes::VERSION';
|
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [qw($exportedVars)] );
|
|
|
|
our \@EXPORT_OK = ( \@{ \$EXPORT_TAGS{'all'} } );
|
|
|
|
our \@EXPORT = ( \@{ \$EXPORT_TAGS{'all'} } );
|
|
|
|
|
|
|
|
our \$specialNodeHash = {
|
|
|
|
virtualHosts => [qw(exportedHeaders locationRules post vhostOptions)],
|
|
|
|
samlIDPMetaDataNodes => [qw(samlIDPMetaDataXML samlIDPMetaDataExportedAttributes samlIDPMetaDataOptions)],
|
2019-10-29 15:20:57 +01:00
|
|
|
samlSPMetaDataNodes => [qw(samlSPMetaDataXML samlSPMetaDataExportedAttributes samlSPMetaDataOptions samlSPMetaDataMacros)],
|
2015-12-27 23:14:43 +01:00
|
|
|
oidcOPMetaDataNodes => [qw(oidcOPMetaDataJSON oidcOPMetaDataJWKS oidcOPMetaDataOptions oidcOPMetaDataExportedVars)],
|
2019-10-29 15:20:57 +01:00
|
|
|
oidcRPMetaDataNodes => [qw(oidcRPMetaDataOptions oidcRPMetaDataExportedVars oidcRPMetaDataOptionsExtraClaims oidcRPMetaDataMacros)],
|
2017-04-12 18:45:55 +02:00
|
|
|
casSrvMetaDataNodes => [qw(casSrvMetaDataOptions casSrvMetaDataExportedVars)],
|
2019-10-29 15:20:57 +01:00
|
|
|
casAppMetaDataNodes => [qw(casAppMetaDataOptions casAppMetaDataExportedVars casAppMetaDataMacros)],
|
2015-12-27 23:14:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2016-02-03 22:30:30 +01:00
|
|
|
# Reinitialize $attributes
|
|
|
|
$attributes = Lemonldap::NG::Manager::Build::Attributes::attributes();
|
|
|
|
|
2016-06-05 08:55:28 +02:00
|
|
|
$ra = Regexp::Assemble->new;
|
|
|
|
foreach (@doubleHashKeys) {
|
|
|
|
$ra->add($_);
|
|
|
|
}
|
|
|
|
print F "our \$doubleHashKeys = '" . $ra->as_string . "';\n";
|
2015-12-27 23:14:43 +01:00
|
|
|
$ra = Regexp::Assemble->new;
|
|
|
|
foreach (@simpleHashKeys) {
|
|
|
|
$ra->add($_);
|
|
|
|
}
|
|
|
|
print F "our \$simpleHashKeys = '" . $ra->as_string . "';\n"
|
|
|
|
. "our \$specialNodeKeys = '${ignoreKeys}s';\n";
|
|
|
|
foreach ( sort keys %cnodesRe ) {
|
|
|
|
print F "our \$${_}Keys = '$cnodesRe{$_}';\n";
|
|
|
|
}
|
2016-03-19 09:23:55 +01:00
|
|
|
print F "\n";
|
|
|
|
|
|
|
|
foreach (qw(authParameters issuerParameters)) {
|
|
|
|
$tmp = "our \$$_ = {\n";
|
|
|
|
no strict 'refs';
|
|
|
|
foreach my $k ( sort keys %$$_ ) {
|
|
|
|
my $v = $$_->{$k};
|
|
|
|
$tmp .= " $k => [qw(" . join( ' ', @$v ) . ")],\n";
|
|
|
|
}
|
|
|
|
print F "$tmp};\n";
|
|
|
|
}
|
2017-04-13 21:17:29 +02:00
|
|
|
foreach (qw(samlServiceParameters oidcServiceParameters)) {
|
2016-03-19 09:23:55 +01:00
|
|
|
no strict 'refs';
|
|
|
|
$tmp = "our \$$_ = [qw(" . join( ' ', @$$_ ) . ")];\n";
|
|
|
|
print F "$tmp";
|
2016-03-18 18:56:59 +01:00
|
|
|
}
|
2016-03-18 18:13:47 +01:00
|
|
|
|
2015-12-27 23:14:43 +01:00
|
|
|
print F "\n1;\n";
|
|
|
|
close F;
|
|
|
|
print STDERR "done\n";
|
|
|
|
|
|
|
|
printf STDERR $format, $self->defaultValuesFile;
|
2016-12-03 19:26:56 +01:00
|
|
|
$defaultValues->{locationRules} = $attributes->{locationRules}->{default};
|
2018-04-03 10:23:31 +02:00
|
|
|
foreach ( keys %$attributes ) {
|
|
|
|
if ( not /(?:MetaData|vhost)/
|
|
|
|
and $attributes->{$_}->{default}
|
|
|
|
and not $reverseScanResult->{$_} )
|
|
|
|
{
|
|
|
|
$defaultValues->{$_} = $attributes->{$_}->{default};
|
|
|
|
}
|
|
|
|
}
|
2016-01-02 10:35:40 +01:00
|
|
|
my $defaultAttr = mydump( $defaultValues, 'defaultValues' );
|
2015-12-28 06:29:34 +01:00
|
|
|
$defaultAttr = "# This file is generated by $module. Don't modify it by hand
|
2015-12-27 23:14:43 +01:00
|
|
|
package Lemonldap::NG::Common::Conf::DefaultValues;
|
|
|
|
|
|
|
|
our \$VERSION = '$Lemonldap::NG::Manager::Build::Attributes::VERSION';
|
|
|
|
|
|
|
|
$defaultAttr}
|
|
|
|
|
|
|
|
1;
|
|
|
|
";
|
|
|
|
|
|
|
|
my $dst;
|
|
|
|
|
|
|
|
eval {
|
|
|
|
require Perl::Tidy;
|
|
|
|
Perl::Tidy::perltidy(
|
|
|
|
source => IO::String->new($defaultAttr),
|
|
|
|
destination => \$dst
|
|
|
|
);
|
|
|
|
};
|
|
|
|
$dst = $defaultAttr if ($@);
|
|
|
|
|
|
|
|
open( F, ">", $self->defaultValuesFile ) or die($!);
|
|
|
|
print F $dst;
|
|
|
|
close F;
|
|
|
|
print STDERR "done\n";
|
|
|
|
|
2016-01-11 07:27:16 +01:00
|
|
|
printf STDERR $format, $self->confConstantsFile;
|
|
|
|
$ra = Regexp::Assemble->new;
|
2018-02-22 16:01:24 +01:00
|
|
|
foreach ( @simpleHashKeys, @doubleHashKeys, sort keys %cnodesRe ) {
|
2016-01-11 07:27:16 +01:00
|
|
|
$ra->add($_);
|
|
|
|
}
|
2019-02-07 09:27:56 +01:00
|
|
|
foreach ( qw(
|
2017-04-12 18:45:55 +02:00
|
|
|
exportedHeaders locationRules post vhostOptions
|
2016-01-12 23:04:07 +01:00
|
|
|
samlIDPMetaDataXML samlIDPMetaDataExportedAttributes
|
|
|
|
samlIDPMetaDataOptions samlSPMetaDataXML
|
2019-10-29 15:20:57 +01:00
|
|
|
samlSPMetaDataExportedAttributes samlSPMetaDataMacros
|
|
|
|
samlSPMetaDataOptions oidcOPMetaDataJSON
|
|
|
|
oidcOPMetaDataJWKS oidcOPMetaDataOptions
|
2016-01-12 23:04:07 +01:00
|
|
|
oidcOPMetaDataExportedVars oidcRPMetaDataOptions
|
2017-04-12 18:45:55 +02:00
|
|
|
oidcRPMetaDataExportedVars oidcRPMetaDataOptionsExtraClaims
|
2021-02-19 08:17:24 +01:00
|
|
|
oidcRPMetaDataMacros oidcRPMetaDataScopeRules
|
|
|
|
casAppMetaDataExportedVars casAppMetaDataOptions casAppMetaDataMacros
|
2017-04-12 18:45:55 +02:00
|
|
|
casSrvMetaDataExportedVars casSrvMetaDataOptions
|
|
|
|
)
|
2016-01-12 23:04:07 +01:00
|
|
|
)
|
|
|
|
{
|
|
|
|
$ra->add($_);
|
|
|
|
}
|
|
|
|
|
2017-01-08 09:42:16 +01:00
|
|
|
my $sessionTypes = join( "', '", @sessionTypes );
|
2016-01-12 23:04:07 +01:00
|
|
|
my $confConstants =
|
|
|
|
"our \$hashParameters = qr/^" . $ra->as_string . "\$/;\n";
|
2019-04-15 11:44:11 +02:00
|
|
|
$ra = Regexp::Assemble->new;
|
2021-02-18 22:08:47 +01:00
|
|
|
foreach (@arrayParam) {
|
|
|
|
$ra->add($_);
|
|
|
|
}
|
|
|
|
|
|
|
|
# Not in Tree.pm
|
|
|
|
foreach (qw(mySessionAuthorizedRWKeys)) {
|
|
|
|
$ra->add($_);
|
|
|
|
}
|
|
|
|
$confConstants .=
|
|
|
|
"our \$arrayParameters = qr/^" . $ra->as_string . "\$/;\n";
|
|
|
|
$ra = Regexp::Assemble->new;
|
2019-04-15 11:44:11 +02:00
|
|
|
foreach (@bool) {
|
|
|
|
$ra->add($_);
|
|
|
|
}
|
|
|
|
$confConstants .= "our \$boolKeys = qr/^" . $ra->as_string . "\$/;\n";
|
2016-01-11 07:27:16 +01:00
|
|
|
open( F, ">", $self->confConstantsFile ) or die($!);
|
|
|
|
print F <<EOF;
|
|
|
|
# This file is generated by $module. Don't modify it by hand
|
|
|
|
package Lemonldap::NG::Common::Conf::Constants;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Exporter 'import';
|
|
|
|
use base qw(Exporter);
|
|
|
|
|
|
|
|
our \$VERSION = '$Lemonldap::NG::Manager::Build::Attributes::VERSION';
|
|
|
|
|
|
|
|
# CONSTANTS
|
|
|
|
|
|
|
|
use constant CONFIG_WAS_CHANGED => -1;
|
|
|
|
use constant UNKNOWN_ERROR => -2;
|
|
|
|
use constant DATABASE_LOCKED => -3;
|
|
|
|
use constant UPLOAD_DENIED => -4;
|
|
|
|
use constant SYNTAX_ERROR => -5;
|
|
|
|
use constant DEPRECATED => -6;
|
|
|
|
use constant DEFAULTCONFFILE => "/usr/local/lemonldap-ng/etc/lemonldap-ng.ini";
|
|
|
|
use constant DEFAULTSECTION => "all";
|
|
|
|
use constant CONFSECTION => "configuration";
|
|
|
|
use constant PORTALSECTION => "portal";
|
|
|
|
use constant HANDLERSECTION => "handler";
|
|
|
|
use constant MANAGERSECTION => "manager";
|
|
|
|
use constant SESSIONSEXPLORERSECTION => "sessionsExplorer";
|
|
|
|
use constant APPLYSECTION => "apply";
|
2020-06-19 16:57:23 +02:00
|
|
|
|
|
|
|
# Default configuration backend
|
|
|
|
use constant DEFAULTCONFBACKEND => "File";
|
|
|
|
use constant DEFAULTCONFBACKENDOPTIONS => (
|
|
|
|
dirName => '/usr/local/lemonldap-ng/data/conf',
|
|
|
|
);
|
2016-01-11 07:27:16 +01:00
|
|
|
$confConstants
|
2017-01-08 09:42:16 +01:00
|
|
|
our \@sessionTypes = ( '$sessionTypes' );
|
2016-01-11 07:27:16 +01:00
|
|
|
|
2017-01-08 07:25:10 +01:00
|
|
|
sub NO {qr/^(?:off|no|0)?\$/i}
|
|
|
|
|
2016-01-11 07:27:16 +01:00
|
|
|
our %EXPORT_TAGS = (
|
|
|
|
'all' => [
|
|
|
|
qw(
|
|
|
|
CONFIG_WAS_CHANGED
|
|
|
|
UNKNOWN_ERROR
|
|
|
|
DATABASE_LOCKED
|
|
|
|
UPLOAD_DENIED
|
|
|
|
SYNTAX_ERROR
|
|
|
|
DEPRECATED
|
|
|
|
DEFAULTCONFFILE
|
|
|
|
DEFAULTSECTION
|
|
|
|
CONFSECTION
|
|
|
|
PORTALSECTION
|
|
|
|
HANDLERSECTION
|
|
|
|
MANAGERSECTION
|
|
|
|
SESSIONSEXPLORERSECTION
|
|
|
|
APPLYSECTION
|
2020-06-19 16:57:23 +02:00
|
|
|
DEFAULTCONFBACKEND
|
|
|
|
DEFAULTCONFBACKENDOPTIONS
|
2017-01-08 07:25:10 +01:00
|
|
|
NO
|
2016-01-11 07:27:16 +01:00
|
|
|
\$hashParameters
|
2021-02-18 22:08:47 +01:00
|
|
|
\$arrayParameters
|
2019-04-03 14:15:16 +02:00
|
|
|
\@sessionTypes
|
2019-04-15 11:44:11 +02:00
|
|
|
\$boolKeys
|
2016-01-11 07:27:16 +01:00
|
|
|
)
|
|
|
|
]
|
|
|
|
);
|
|
|
|
our \@EXPORT_OK = ( \@{ \$EXPORT_TAGS{'all'} } );
|
|
|
|
our \@EXPORT = ( \@{ \$EXPORT_TAGS{'all'} } );
|
|
|
|
|
|
|
|
1;
|
|
|
|
EOF
|
|
|
|
close F;
|
|
|
|
print STDERR "done\n";
|
|
|
|
|
2015-12-27 23:14:43 +01:00
|
|
|
printf STDERR $format, $self->managerAttributesFile;
|
|
|
|
my $managerAttr = {
|
|
|
|
map {
|
|
|
|
my @r;
|
|
|
|
foreach my $f (@managerAttrKeys) {
|
|
|
|
push @r, $f, $attributes->{$_}->{$f}
|
|
|
|
if ( defined $attributes->{$_}->{$f} );
|
|
|
|
}
|
|
|
|
( $_ => {@r} );
|
|
|
|
} keys(%$attributes)
|
|
|
|
};
|
2016-01-02 10:35:40 +01:00
|
|
|
$managerAttr = mydump( $managerAttr, 'attributes' );
|
2019-06-14 17:23:26 +02:00
|
|
|
my $managerSub =
|
|
|
|
Dumper( \&Lemonldap::NG::Manager::Build::Attributes::perlExpr );
|
2019-06-10 08:56:56 +02:00
|
|
|
$managerSub =~ s/\$VAR1 = sub/sub perlExpr/s;
|
|
|
|
$managerSub =~ s/^\s*(?:use strict;|package .*?;|)\n//gm;
|
2015-12-27 23:14:43 +01:00
|
|
|
my $managerTypes =
|
2016-01-02 10:35:40 +01:00
|
|
|
mydump( Lemonldap::NG::Manager::Build::Attributes::types(), 'types' );
|
2015-12-28 06:29:34 +01:00
|
|
|
$managerAttr = "# This file is generated by $module. Don't modify it by hand
|
2015-12-27 23:14:43 +01:00
|
|
|
package Lemonldap::NG::Manager::Attributes;
|
|
|
|
|
|
|
|
our \$VERSION = '$Lemonldap::NG::Manager::Build::Attributes::VERSION';
|
|
|
|
|
2019-06-10 08:56:56 +02:00
|
|
|
$managerSub
|
|
|
|
|
2015-12-27 23:14:43 +01:00
|
|
|
$managerTypes}
|
|
|
|
|
|
|
|
$managerAttr}
|
|
|
|
|
|
|
|
";
|
|
|
|
eval {
|
|
|
|
Perl::Tidy::perltidy(
|
|
|
|
source => IO::String->new($managerAttr),
|
|
|
|
destination => \$dst
|
|
|
|
);
|
|
|
|
};
|
|
|
|
$dst = $managerAttr if ($@);
|
|
|
|
|
|
|
|
open( F, ">", $self->managerAttributesFile ) or die($!);
|
|
|
|
print F $dst;
|
|
|
|
close F;
|
|
|
|
print STDERR "done\n";
|
2016-01-05 22:33:49 +01:00
|
|
|
|
|
|
|
$self->buildZeroConf();
|
2016-03-22 21:48:30 +01:00
|
|
|
|
|
|
|
printf STDERR $format, $self->reverseTreeFile;
|
|
|
|
open( F, ">", $self->reverseTreeFile ) or die($!);
|
|
|
|
$jsonEnc->pretty(0);
|
2018-04-03 10:23:31 +02:00
|
|
|
print F $jsonEnc->encode($reverseScanResult);
|
2016-03-22 21:48:30 +01:00
|
|
|
close F;
|
2019-09-17 20:17:57 +02:00
|
|
|
|
2016-03-22 21:48:30 +01:00
|
|
|
print STDERR "done\n";
|
2019-09-17 20:17:57 +02:00
|
|
|
$self->buildPortalConstants();
|
2016-01-05 22:33:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub buildZeroConf {
|
|
|
|
my $self = shift;
|
|
|
|
$jsonEnc->pretty(1);
|
|
|
|
printf STDERR $format, $self->firstLmConfFile;
|
|
|
|
open( F, '>', $self->firstLmConfFile ) or die($!);
|
2016-01-18 19:40:47 +01:00
|
|
|
my $tmp = Lemonldap::NG::Manager::Conf::Zero::zeroConf(
|
2016-01-22 17:53:41 +01:00
|
|
|
'__DNSDOMAIN__', '__SESSIONDIR__',
|
2020-11-05 21:01:52 +01:00
|
|
|
'__PSESSIONDIR__', '__NOTIFICATIONDIR__',
|
|
|
|
'__CACHEDIR__'
|
2016-01-22 17:53:41 +01:00
|
|
|
);
|
2016-01-18 19:40:47 +01:00
|
|
|
$tmp->{cfgNum} = 1;
|
|
|
|
print F $jsonEnc->encode($tmp);
|
2016-01-05 22:33:49 +01:00
|
|
|
close F;
|
|
|
|
print STDERR "done\n";
|
2015-12-27 23:14:43 +01:00
|
|
|
}
|
|
|
|
|
2019-09-17 20:17:57 +02:00
|
|
|
sub buildPortalConstants() {
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
my %portalConstants =
|
|
|
|
%{ Lemonldap::NG::Manager::Build::PortalConstants::portalConstants() };
|
|
|
|
my %reverseConstants = reverse %portalConstants;
|
|
|
|
die "Duplicate value in portal constants"
|
|
|
|
unless %reverseConstants == %portalConstants;
|
|
|
|
|
|
|
|
printf STDERR $format, $self->portalConstantsFile;
|
|
|
|
open( F, '>', $self->portalConstantsFile ) or die($!);
|
|
|
|
my $content = <<EOF;
|
|
|
|
# This file is generated by $module. Don't modify it by hand
|
|
|
|
package Lemonldap::NG::Portal::Main::Constants;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Exporter 'import';
|
|
|
|
|
|
|
|
our \$VERSION = '$Lemonldap::NG::Manager::Build::Attributes::VERSION';
|
|
|
|
|
|
|
|
use constant HANDLER => 'Lemonldap::NG::Handler::PSGI::Main';
|
|
|
|
use constant {
|
|
|
|
EOF
|
2020-02-20 23:34:02 +01:00
|
|
|
for my $pe (
|
|
|
|
sort { $portalConstants{$a} <=> $portalConstants{$b} }
|
|
|
|
keys %portalConstants
|
|
|
|
)
|
2019-09-17 20:17:57 +02:00
|
|
|
{
|
|
|
|
my $str = $portalConstants{$pe};
|
|
|
|
$content .= " $pe => $str,\n";
|
|
|
|
}
|
|
|
|
|
2020-02-20 23:34:02 +01:00
|
|
|
my $exports = join ", ", map { "'$_'" }
|
2019-09-17 20:17:57 +02:00
|
|
|
sort { $portalConstants{$a} <=> $portalConstants{$b} }
|
|
|
|
keys %portalConstants;
|
|
|
|
|
|
|
|
my $portalConstsStr .= mydump( \%reverseConstants, 'portalConsts' );
|
|
|
|
$content .= <<EOF;
|
|
|
|
};
|
|
|
|
|
|
|
|
$portalConstsStr
|
|
|
|
}
|
|
|
|
|
|
|
|
# EXPORTER PARAMETERS
|
|
|
|
our \@EXPORT_OK = ( 'portalConsts', 'HANDLER', $exports );
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ \@EXPORT_OK, 'import' ], );
|
|
|
|
|
|
|
|
our \@EXPORT = qw(import PE_OK);
|
|
|
|
|
|
|
|
1;
|
|
|
|
EOF
|
|
|
|
|
|
|
|
my $dst;
|
|
|
|
eval {
|
|
|
|
Perl::Tidy::perltidy(
|
|
|
|
source => IO::String->new($content),
|
|
|
|
destination => \$dst
|
|
|
|
);
|
|
|
|
};
|
|
|
|
$dst = $content if ($@);
|
|
|
|
open( F, '>', $self->portalConstantsFile ) or die($!);
|
|
|
|
print F $dst;
|
|
|
|
close F;
|
|
|
|
print STDERR "done\n";
|
|
|
|
|
|
|
|
printf STDERR $format, $self->handlerStatusConstantsFile;
|
|
|
|
|
|
|
|
# Handler Status file
|
2019-09-17 21:42:42 +02:00
|
|
|
$content = <<EOF;
|
2019-09-17 20:17:57 +02:00
|
|
|
# This file is generated by $module. Don't modify it by hand
|
|
|
|
package Lemonldap::NG::Handler::Lib::StatusConstants;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Exporter 'import';
|
|
|
|
|
|
|
|
our \$VERSION = '$Lemonldap::NG::Manager::Build::Attributes::VERSION';
|
|
|
|
|
|
|
|
$portalConstsStr
|
|
|
|
}
|
|
|
|
|
|
|
|
# EXPORTER PARAMETERS
|
|
|
|
our \@EXPORT_OK = ( 'portalConsts' );
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ \@EXPORT_OK, 'import' ], );
|
|
|
|
|
|
|
|
1;
|
|
|
|
EOF
|
|
|
|
|
|
|
|
eval {
|
|
|
|
Perl::Tidy::perltidy(
|
|
|
|
source => IO::String->new($content),
|
|
|
|
destination => \$dst
|
|
|
|
);
|
|
|
|
};
|
|
|
|
$dst = $content if ($@);
|
|
|
|
open( F, '>', $self->handlerStatusConstantsFile ) or die($!);
|
|
|
|
print F $dst;
|
|
|
|
close F;
|
|
|
|
print STDERR "done\n";
|
|
|
|
}
|
|
|
|
|
2015-12-30 21:16:15 +01:00
|
|
|
sub mydump {
|
2016-01-02 10:35:40 +01:00
|
|
|
my ( $obj, $subname ) = @_;
|
2015-12-30 21:16:15 +01:00
|
|
|
my $t = Dumper($obj);
|
|
|
|
$t =~ s/^\s*(?:use strict;|package .*?;|)\n//gm;
|
2018-06-19 20:56:13 +02:00
|
|
|
$t =~ s/\n\s*BEGIN.*?\}\n/\n/sg;
|
2015-12-30 21:16:15 +01:00
|
|
|
$t =~ s/^\$VAR1\s*=/sub $subname {\n return/;
|
|
|
|
return $t;
|
|
|
|
}
|
|
|
|
|
2015-12-27 23:14:43 +01:00
|
|
|
sub scanTree {
|
2016-01-02 10:29:05 +01:00
|
|
|
my ( $self, $tree, $json, $prefix, $path ) = @_;
|
2015-12-27 23:14:43 +01:00
|
|
|
unless ( ref($tree) eq 'ARRAY' ) {
|
|
|
|
die 'Not an array';
|
|
|
|
}
|
|
|
|
$prefix //= '';
|
2019-07-02 20:03:40 +02:00
|
|
|
my $ord = -1;
|
2015-12-27 23:14:43 +01:00
|
|
|
my $nodeName = $path ? '_nodes' : 'data';
|
|
|
|
foreach my $leaf (@$tree) {
|
|
|
|
$ord++;
|
|
|
|
my $jleaf = {};
|
|
|
|
|
|
|
|
# Grouped leaf
|
|
|
|
if ( ref($leaf) and $leaf->{group} ) {
|
|
|
|
die "'form' is required when using 'group'"
|
|
|
|
unless ( $leaf->{form} );
|
|
|
|
push @$json,
|
|
|
|
{
|
|
|
|
id => "$prefix$leaf->{title}",
|
|
|
|
title => $leaf->{title},
|
|
|
|
type => $leaf->{form},
|
|
|
|
get => $leaf->{group}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
# Subnode
|
|
|
|
elsif ( ref($leaf) ) {
|
|
|
|
$jleaf->{title} = $jleaf->{id} = $leaf->{title};
|
2020-05-24 00:04:33 +02:00
|
|
|
$jleaf->{type} = $leaf->{form} if ( $leaf->{form} );
|
2017-04-12 18:45:55 +02:00
|
|
|
if ( $leaf->{title} =~ /^((?:oidc|saml|cas)Service)MetaData$/ ) {
|
2016-03-19 09:23:55 +01:00
|
|
|
no strict 'refs';
|
|
|
|
my @tmp = $self->scanLeaf( $leaf->{nodes} );
|
|
|
|
${ $1 . 'Parameters' } = \@tmp;
|
|
|
|
}
|
2015-12-27 23:14:43 +01:00
|
|
|
foreach my $n (qw(nodes nodes_cond)) {
|
|
|
|
if ( $leaf->{$n} ) {
|
|
|
|
$jleaf->{"_$n"} = [];
|
|
|
|
$self->scanTree( $leaf->{$n}, $jleaf->{"_$n"}, $prefix,
|
|
|
|
"$path.$nodeName\[$ord\]" );
|
2019-02-07 09:27:56 +01:00
|
|
|
if ( (
|
2016-03-19 09:23:55 +01:00
|
|
|
$leaf->{title} eq 'authParams'
|
|
|
|
and $n eq 'nodes_cond'
|
|
|
|
)
|
|
|
|
or $leaf->{title} eq 'issuerParams'
|
|
|
|
)
|
|
|
|
{
|
|
|
|
my $vn = $leaf->{title};
|
|
|
|
$vn =~ s/Params$/Parameters/;
|
|
|
|
foreach my $sn ( @{ $leaf->{$n} } ) {
|
|
|
|
no strict 'refs';
|
2016-03-18 18:13:47 +01:00
|
|
|
my @cn = $self->scanLeaf( $sn->{nodes} );
|
2016-03-19 09:23:55 +01:00
|
|
|
${$vn}->{ $sn->{title} } = \@cn;
|
2016-03-18 18:13:47 +01:00
|
|
|
}
|
2016-03-19 09:23:55 +01:00
|
|
|
}
|
|
|
|
elsif ( $leaf->{title} eq 'issuerParams' ) {
|
|
|
|
}
|
|
|
|
if ( $n eq 'nodes_cond' ) {
|
2015-12-27 23:14:43 +01:00
|
|
|
foreach my $sn ( @{ $jleaf->{"_$n"} } ) {
|
|
|
|
$sn->{show} = 'false';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-07-02 20:03:40 +02:00
|
|
|
$jleaf->{help} = $leaf->{help} if ( $leaf->{help} );
|
2015-12-27 23:14:43 +01:00
|
|
|
$jleaf->{_nodes_filter} = $leaf->{nodes_filter}
|
|
|
|
if ( $leaf->{nodes_filter} );
|
|
|
|
push @$json, $jleaf;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Leaf
|
|
|
|
else {
|
|
|
|
# Get data type and build tree
|
|
|
|
#
|
2021-02-18 22:08:47 +01:00
|
|
|
# Types : PerlModule array bool boolOrExpr catAndAppList file
|
|
|
|
# hostname int keyTextContainer lmAttrOrMacro longtext
|
|
|
|
# openidServerList oidcAttributeContainer pcre rulesContainer
|
|
|
|
# samlAssertion samlAttributeContainer samlService select text
|
|
|
|
# trool url virtualHostContainer word password
|
2015-12-27 23:14:43 +01:00
|
|
|
|
|
|
|
if ( $leaf =~ s/^\*// ) {
|
|
|
|
push @angularScopeVars, [ $leaf, "$path._nodes[$ord]" ];
|
|
|
|
}
|
|
|
|
push @sessionTypes, $1
|
|
|
|
if ( $leaf =~ /^(.*)(?<!notification)StorageOptions$/ );
|
|
|
|
my $attr = $attributes->{$leaf} or die("Missing attribute $leaf");
|
2017-03-27 18:51:18 +02:00
|
|
|
|
2017-03-13 08:49:37 +01:00
|
|
|
#print STDERR "| $attr->{documentation} | $leaf |\n";
|
2015-12-27 23:14:43 +01:00
|
|
|
$jleaf = { id => "$prefix$leaf", title => $leaf };
|
|
|
|
unless ( $attr->{type} ) {
|
|
|
|
print STDERR "Fatal: no type: $leaf\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
# TODO: change this
|
|
|
|
$attr->{type} =~
|
|
|
|
s/^(?:url|word|pcre|lmAttrOrMacro|hostname|PerlModule)$/text/;
|
|
|
|
$jleaf->{type} = $attr->{type} if ( $attr->{type} ne 'text' );
|
2016-01-21 07:02:02 +01:00
|
|
|
foreach my $w (qw(default help select get template)) {
|
2015-12-27 23:14:43 +01:00
|
|
|
$jleaf->{$w} = $attr->{$w} if ( defined $attr->{$w} );
|
|
|
|
}
|
2016-12-03 19:26:56 +01:00
|
|
|
if ( defined $jleaf->{default} ) {
|
2017-01-24 22:02:04 +01:00
|
|
|
unless ( $attr->{type} eq 'bool' and $jleaf->{default} == 0 ) {
|
|
|
|
$defaultValues->{$leaf} = $jleaf->{default};
|
|
|
|
}
|
2016-12-03 19:26:56 +01:00
|
|
|
if ( ref( $jleaf->{default} ) ) {
|
|
|
|
$jleaf->{default} = [];
|
|
|
|
my $type = $attr->{type};
|
|
|
|
$type =~ s/Container//;
|
|
|
|
foreach my $k ( sort keys( %{ $attr->{default} } ) ) {
|
2020-11-05 21:01:52 +01:00
|
|
|
# Special handling for oidcAttribute
|
|
|
|
my $default = $attr->{default}->{$k};
|
|
|
|
if ( $attr->{type} eq 'oidcAttributeContainer' ) {
|
|
|
|
$default = [ $default, "string", "auto" ];
|
|
|
|
}
|
|
|
|
|
2016-12-03 19:26:56 +01:00
|
|
|
push @{ $jleaf->{default} },
|
|
|
|
{
|
|
|
|
id => "$prefix$leaf/$k",
|
|
|
|
title => $k,
|
|
|
|
type => $type,
|
2020-11-05 21:01:52 +01:00
|
|
|
data => $default,
|
2016-12-03 19:26:56 +01:00
|
|
|
(
|
|
|
|
$type eq 'rule'
|
|
|
|
? ( re => $k )
|
|
|
|
: ()
|
|
|
|
),
|
|
|
|
};
|
|
|
|
}
|
2015-12-27 23:14:43 +01:00
|
|
|
}
|
|
|
|
}
|
2021-03-30 16:30:22 +02:00
|
|
|
|
2015-12-27 23:14:43 +01:00
|
|
|
if ($prefix) {
|
|
|
|
push @cnodesKeys, $leaf;
|
|
|
|
}
|
2021-03-30 16:30:22 +02:00
|
|
|
|
|
|
|
# issue 2439
|
|
|
|
# FIXME: in future versions, oidcOPMetaDataJSON and samlIDPMetaDataXML shoud
|
|
|
|
# behave the same
|
|
|
|
if ( $leaf =~ /^oidcOPMetaData(?:JSON|JWKS)$/ ) {
|
|
|
|
push @simpleHashKeys, $leaf;
|
|
|
|
}
|
|
|
|
|
2015-12-27 23:14:43 +01:00
|
|
|
if ( $attr->{type} =~ /^(?:catAndAppList|\w+Container)$/ ) {
|
|
|
|
$jleaf->{cnodes} = $prefix . $leaf;
|
|
|
|
unless ( $prefix or $leaf =~ $reIgnoreKeys ) {
|
|
|
|
push @simpleHashKeys, $leaf;
|
|
|
|
}
|
|
|
|
}
|
2016-06-05 08:55:28 +02:00
|
|
|
elsif ( $attr->{type} eq 'doubleHash' and $leaf !~ $reIgnoreKeys ) {
|
|
|
|
push @doubleHashKeys, $leaf;
|
|
|
|
}
|
2015-12-27 23:14:43 +01:00
|
|
|
else {
|
|
|
|
if ( $prefix and !$jleaf->{get} ) {
|
|
|
|
$jleaf->{get} = $prefix . $jleaf->{title};
|
2019-04-15 11:44:11 +02:00
|
|
|
}
|
|
|
|
if ( $attr->{type} eq 'bool' ) {
|
|
|
|
push @bool, $leaf;
|
2021-02-18 22:08:47 +01:00
|
|
|
}
|
|
|
|
if ( $attr->{type} eq 'array' ) {
|
|
|
|
push @arrayParam, $leaf;
|
2015-12-27 23:14:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
push @$json, $jleaf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-18 18:13:47 +01:00
|
|
|
sub scanLeaf {
|
2016-03-19 09:23:55 +01:00
|
|
|
my ( $self, $tree ) = @_;
|
|
|
|
my @res;
|
|
|
|
foreach my $k (@$tree) {
|
|
|
|
if ( ref $k ) {
|
|
|
|
push @res, $self->scanLeaf1( $k->{nodes} || $k->{group} );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
push @res, $k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return @res;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub scanLeaf1 {
|
|
|
|
my ( $self, $tree ) = @_;
|
2016-03-18 18:13:47 +01:00
|
|
|
my @res;
|
|
|
|
foreach my $k (@$tree) {
|
2016-03-19 09:23:55 +01:00
|
|
|
if ( ref $k ) {
|
|
|
|
push @res, $self->scanLeaf( $k->{nodes} || $k->{group} );
|
2016-03-18 18:13:47 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
push @res, $k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return @res;
|
|
|
|
}
|
|
|
|
|
2016-03-22 21:48:30 +01:00
|
|
|
sub reverseScan {
|
|
|
|
my ( $self, $tree, $path, $res ) = @_;
|
2016-04-29 09:27:26 +02:00
|
|
|
foreach my $elem (@$tree) {
|
2016-03-22 21:48:30 +01:00
|
|
|
$elem =~ s/^\*//;
|
|
|
|
if ( ref($elem) eq 'HASH' ) {
|
|
|
|
foreach (qw(nodes nodes_cond group)) {
|
2016-04-29 09:27:26 +02:00
|
|
|
$self->reverseScan( $elem->{$_}, "$path$elem->{title}/", $res )
|
|
|
|
if ( $elem->{$_} );
|
2016-03-22 21:48:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
my $tmp = $path;
|
|
|
|
$tmp =~ s#/$##;
|
|
|
|
$res->{$elem} = $tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
2015-12-27 23:14:43 +01:00
|
|
|
1;
|
2015-12-28 06:29:34 +01:00
|
|
|
__END__
|
2015-12-28 06:38:42 +01:00
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
=encoding utf8
|
|
|
|
|
|
|
|
Lemonldap::NG::Manager::Build - Static files generator of Lemonldap::NG Web-SSO
|
|
|
|
system.
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
use Lemonldap::NG::Manager::Build;
|
|
|
|
|
|
|
|
Lemonldap::NG::Manager::Build->run(
|
2017-02-27 07:08:22 +01:00
|
|
|
structFile => "site/htdocs/static/struct.json",
|
|
|
|
confTreeFile => "site/htdocs/static/js/conftree.js",
|
2017-01-10 22:43:37 +01:00
|
|
|
managerConstantsFile => "lib/Lemonldap/NG/Common/Conf/ReConstants.pm",
|
2015-12-28 06:38:42 +01:00
|
|
|
managerAttributesFile => 'lib/Lemonldap/NG/Manager/Attributes.pm',
|
|
|
|
defaultValuesFile => "lib/Lemonldap/NG/Common/Conf/DefaultValues.pm",
|
2017-01-27 12:58:46 +01:00
|
|
|
firstLmConfFile => "_example/conf/lmConf-1.json",
|
2017-02-27 07:08:22 +01:00
|
|
|
reverseTreeFile => "site/htdocs/static/reverseTree.json",
|
2015-12-28 06:38:42 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
Lemonldap::NG::Manager::Build is only used to build javascript files and
|
|
|
|
Lemonldap::NG constants Perl files. It must be launched after each change.
|
2015-12-30 21:16:15 +01:00
|
|
|
|
2017-02-07 15:46:28 +01:00
|
|
|
=head2 DEVELOPER CORNER
|
2015-12-30 21:16:15 +01:00
|
|
|
|
|
|
|
To add a new parameter, you have to:
|
|
|
|
|
|
|
|
=over
|
|
|
|
|
|
|
|
=item declare it in Manager/Build/Attributes.pm;
|
|
|
|
|
|
|
|
=item declare its position in the tree in Manager/Build/Tree.pm (or
|
|
|
|
Manager/Build/CTrees.pm for complex nodes);
|
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
=item refresh files by using this (or launch any build makefile target at the
|
2015-12-30 21:16:15 +01:00
|
|
|
root of the Lemonldap::NG project sources).
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
See below for details.
|
|
|
|
|
2017-01-05 06:57:16 +01:00
|
|
|
=head3 Files generated
|
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
`scripts/jsongenerator.pl` file uses Lemonldap::NG::Manager::Build::Attributes,
|
2017-01-05 06:57:16 +01:00
|
|
|
Lemonldap::NG::Manager::Build::Tree and Lemonldap::NG::Manager::Build::CTrees to generate
|
|
|
|
|
|
|
|
=over
|
|
|
|
|
2017-02-27 07:08:22 +01:00
|
|
|
=item `site/htdocs/static/struct.json`:
|
2017-01-05 06:57:16 +01:00
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
Main file containing the tree view;
|
2017-01-05 06:57:16 +01:00
|
|
|
|
2017-02-27 07:08:22 +01:00
|
|
|
=item `site/htdocs/static/js/conftree.js`:
|
2017-01-05 06:57:16 +01:00
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
generates Virtualhosts, SAML and OpenID-Connect partners sub-trees;
|
2017-01-05 06:57:16 +01:00
|
|
|
|
2017-02-27 07:08:22 +01:00
|
|
|
=item `site/htdocs/static/reverseTree.json`:
|
2017-01-05 06:57:16 +01:00
|
|
|
|
|
|
|
map used by manager diff to find attribute position in the tree;
|
|
|
|
|
|
|
|
=item `Lemonldap::NG::Manager::Constants`:
|
|
|
|
|
|
|
|
constants used by all Perl manager components;
|
|
|
|
|
|
|
|
=item `Lemonldap::NG::Common::Conf::DefaultValues`:
|
|
|
|
|
|
|
|
constants used to read configuration;
|
|
|
|
|
|
|
|
=item `Lemonldap::NG::Manager::Attributes`:
|
|
|
|
|
|
|
|
parameters attributes used by the manager during configuration upload;
|
|
|
|
|
2017-01-27 12:58:46 +01:00
|
|
|
=item lmConf-1.json:
|
2017-01-05 06:57:16 +01:00
|
|
|
|
|
|
|
first configuration in file format;
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
2015-12-30 21:16:15 +01:00
|
|
|
=head3 Attribute declaration
|
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
set your new attribute as a key of attributes() function that points to a hash
|
2015-12-30 21:16:15 +01:00
|
|
|
ref containing:
|
|
|
|
|
|
|
|
=over
|
|
|
|
|
|
|
|
=item type (required):
|
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
content type must be declared in sub types() in the same file
|
|
|
|
(except if attribute embeds its own tests) and must match
|
|
|
|
to a form stored in static/forms/ directory;
|
2015-12-30 21:16:15 +01:00
|
|
|
|
|
|
|
=item help (optional):
|
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
Relative HTML path to help page (relative to
|
2015-12-30 21:16:15 +01:00
|
|
|
/doc/pages/documentation/<version>/);
|
|
|
|
|
|
|
|
=item default (recommended):
|
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
default value to set if not defined;
|
2015-12-30 21:16:15 +01:00
|
|
|
|
|
|
|
=item select (optional):
|
|
|
|
|
|
|
|
required only if type is `select`. In this case, it
|
2018-08-22 13:01:24 +02:00
|
|
|
must contain an array of { k => <keyName>, v => <display name> } hashref
|
2015-12-30 21:16:15 +01:00
|
|
|
|
|
|
|
=item documentation (recommended):
|
|
|
|
|
2019-09-24 19:24:39 +02:00
|
|
|
some words for other developers
|
2015-12-30 21:16:15 +01:00
|
|
|
|
|
|
|
=item test (optional):
|
|
|
|
|
|
|
|
if test is not defined for this type or if test must
|
2018-08-22 13:01:24 +02:00
|
|
|
be more restrictive, set here a regular expression or a subroutine. Arguments
|
|
|
|
passed to subroutine are (keyValue, newConf, currentKey). It returns 2
|
2019-04-03 14:15:16 +02:00
|
|
|
arguments: a boolean result and a message (if non empty message will be
|
2018-08-22 13:01:24 +02:00
|
|
|
displayed as warning or error depending of result);
|
2015-12-30 21:16:15 +01:00
|
|
|
|
|
|
|
=item msgFail (optional):
|
|
|
|
|
|
|
|
for regexp based tests, message to display in case of
|
|
|
|
error. Words to translate have to be written as so: __toTranslate__;
|
|
|
|
|
|
|
|
=item keyTest (optional):
|
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
for keys/values attributes, test to be applied on key;
|
2015-12-30 21:16:15 +01:00
|
|
|
|
|
|
|
=item keyMsgFail (optional):
|
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
for regexp based key tests, same as msgFail for keys test;
|
2015-12-30 21:16:15 +01:00
|
|
|
|
|
|
|
=back
|
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
If you want to declare a new type, you have to declare following
|
2015-12-30 21:16:15 +01:00
|
|
|
properties:
|
|
|
|
|
|
|
|
=over
|
|
|
|
|
|
|
|
=item test, msgFail, keyTest, keyMsgFail as shown above,
|
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
=item form: form to use if it doesn't have the same name.
|
2015-12-30 21:16:15 +01:00
|
|
|
|
|
|
|
=back
|
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
=head3 Tree location
|
2015-12-30 21:16:15 +01:00
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
The tree is now very simple: it contains nodes and leaves. Leaves are designed only
|
2015-12-30 21:16:15 +01:00
|
|
|
by their attribute name. All description must be done in the file described
|
|
|
|
above. Nodes are array member designed as this:
|
|
|
|
|
|
|
|
{
|
|
|
|
title => 'titleToTranslate',
|
|
|
|
help => 'helpUrl',
|
|
|
|
form => 'relativeUrl',
|
|
|
|
nodes => [
|
|
|
|
... nodes or leaf ...
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
Explanations:
|
|
|
|
|
|
|
|
=over
|
|
|
|
|
|
|
|
=item title (required):
|
|
|
|
|
|
|
|
it must contain an entry of static/languages/lang.json
|
|
|
|
|
|
|
|
=item help (recommended):
|
|
|
|
|
|
|
|
as above, the relative HTML path to the help page
|
|
|
|
(relative to /doc/pages/documentation/<version>/);
|
|
|
|
|
|
|
|
=item form (optional):
|
|
|
|
|
|
|
|
the name of a static/forms/<name>.html file
|
|
|
|
|
|
|
|
=item nodes:
|
|
|
|
|
|
|
|
array of sub nodes and leaf attached to this node
|
|
|
|
|
|
|
|
=item group:
|
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
must never be used in conjunction with nodes. Array of leaves only
|
2015-12-30 21:16:15 +01:00
|
|
|
to be displayed in the same form
|
|
|
|
|
|
|
|
=item nodes_cond:
|
|
|
|
|
2018-08-22 13:01:24 +02:00
|
|
|
array of sub nodes that will be displayed with a filter. Not yet
|
|
|
|
documented here, see the source code of site/htdocs/static/js/filterFunctions.js.
|
2015-12-30 21:16:15 +01:00
|
|
|
|
|
|
|
=item nodes_filter:
|
|
|
|
|
2017-02-27 07:08:22 +01:00
|
|
|
filter entry in site/htdocs/static/js/filterFunctions.js for the same feature.
|
2015-12-30 21:16:15 +01:00
|
|
|
|
|
|
|
=back
|
2015-12-28 06:38:42 +01:00
|
|
|
|
|
|
|
=head1 SEE ALSO
|
|
|
|
|
2017-01-04 21:37:29 +01:00
|
|
|
L<http://lemonldap-ng.org/>
|
2015-12-28 06:38:42 +01:00
|
|
|
|
|
|
|
=head1 AUTHORS
|
|
|
|
|
|
|
|
=over
|
|
|
|
|
2017-01-04 21:37:29 +01:00
|
|
|
=item LemonLDAP::NG team L<http://lemonldap-ng.org/team>
|
2015-12-28 06:38:42 +01:00
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
=head1 BUG REPORT
|
|
|
|
|
|
|
|
Use OW2 system to report bug or ask for features:
|
2017-11-11 14:06:23 +01:00
|
|
|
L<https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/issues>
|
2015-12-28 06:38:42 +01:00
|
|
|
|
2017-01-05 06:57:16 +01:00
|
|
|
Note that if you want to post a ticket for a conf upload problem, please
|
|
|
|
see L<Lemonldap::NG::Manager::Conf::Parser> before.
|
|
|
|
|
2015-12-28 06:38:42 +01:00
|
|
|
=head1 DOWNLOAD
|
|
|
|
|
|
|
|
Lemonldap::NG is available at
|
|
|
|
L<http://forge.objectweb.org/project/showfiles.php?group_id=274>
|
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE
|
|
|
|
|
2017-01-04 21:37:29 +01:00
|
|
|
See COPYING file for details.
|
2015-12-28 06:38:42 +01:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see L<http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
=cut
|