Commit 93b3522e authored by Xavier Guimard's avatar Xavier Guimard

Restore subs (were transformed in "DUMMY") + doc

parent 93f7d507
......@@ -67,7 +67,7 @@ sub defaultValues {
'issuerDBCASPath' => '^/cas/',
'issuerDBCASRule' => 1,
'issuerDBOpenIDActivation' => 0,
'issuerDBOpenIDConnectActivation' => '0',
'issuerDBOpenIDConnectActivation' => 0,
'issuerDBOpenIDConnectPath' => '^/oauth2/',
'issuerDBOpenIDConnectRule' => 1,
'issuerDBOpenIDPath' => '^/openidserver/',
......@@ -139,10 +139,10 @@ sub defaultValues {
'oidcAuthnLevel' => 1,
'oidcRPCallbackGetParam' => 'openidconnectcallback',
'oidcRPStateTimeout' => 600,
'oidcServiceAllowAuthorizationCodeFlow' => '1',
'oidcServiceAllowDynamicRegistration' => '0',
'oidcServiceAllowHybridFlow' => '0',
'oidcServiceAllowImplicitFlow' => '0',
'oidcServiceAllowAuthorizationCodeFlow' => 1,
'oidcServiceAllowDynamicRegistration' => 0,
'oidcServiceAllowHybridFlow' => 0,
'oidcServiceAllowImplicitFlow' => 0,
'oidcServiceMetaDataAuthnContext' => {
'loa-1' => 1,
'loa-2' => 2,
......
......@@ -26,7 +26,4 @@
## Doc
* Wiki doc
* Developer corner:
* adding a configurationkey
* adding a data type
......@@ -6,10 +6,14 @@ our $VERSION = '1.9.0';
sub types {
return {
'authParamsText' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'blackWhiteList' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'bool' => {
'msgFail' => '__notABoolean__',
......@@ -17,13 +21,24 @@ sub types {
},
'boolOrExpr' => {
'msgFail' => '__notAValidPerlExpression__',
'test' => sub { "DUMMY" }
'test' => sub {
my $s = eval {
do {
$_[0];
}
};
return $@ ? ( 0, "__badExpression__: $@" ) : 1;
}
},
'catAndAppList' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'file' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'hostname' => {
'form' => 'text',
......@@ -42,28 +57,44 @@ qr/^(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-
},
'lmAttrOrMacro' => {
'form' => 'text',
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'longtext' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'menuApp' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'menuCat' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'oidcmetadatajson' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'oidcmetadatajwks' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'oidcOPMetaDataNode' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'oidcRPMetaDataNode' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'password' => {
'msgFail' => '__malformedValue__',
......@@ -71,7 +102,14 @@ qr/^(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-
},
'pcre' => {
'form' => 'text',
'test' => sub { "DUMMY" }
'test' => sub {
eval {
do {
qr/$_[0]/;
}
};
return $@ ? ( 0, "__badRegexp__: $@" ) : 1;
}
},
'PerlModule' => {
'form' => 'text',
......@@ -79,13 +117,19 @@ qr/^(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-
'test' => qr/^[a-zA-Z][a-zA-Z0-9]*(?:::[a-zA-Z][a-zA-Z0-9]*)*$/
},
'portalskin' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'portalskinbackground' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'post' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'RSAPrivateKey' => {
'msgFail' => '__badPemEncoding__',
......@@ -98,25 +142,42 @@ qr/^(?:(?:\-+\s*BEGIN\s+RSA\s+PRIVATE\s+KEY\s*\-+\r?\n)?[a-zA-Z0-9\/\+\r\n]+={0,
qr/^(?:(?:\-+\s*BEGIN\s+PUBLIC\s+KEY\s*\-+\r?\n)?[a-zA-Z0-9\/\+\r\n]+={0,2}(?:\r?\n\-+\s*END\s+PUBLIC\s+KEY\s*\-+)?[\r\n]*)?$/s
},
'rule' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'samlAssertion' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'samlAttribute' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'samlIDPMetaDataNode' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'samlService' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'samlSPMetaDataNode' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
},
'select' => {
'test' => sub { "DUMMY" }
'test' => sub {
my $test =
grep( { $_ eq $_[0]; }
map( { $$_{'k'}; } @{ $_[2]{'select'}; } ) );
return $test ? 1 : 0;
}
},
'text' => {
'msgFail' => '__malformedValue__',
......@@ -133,7 +194,9 @@ qr/^(?:(?:\-+\s*BEGIN\s+PUBLIC\s+KEY\s*\-+\r?\n)?[a-zA-Z0-9\/\+\r\n]+={0,2}(?:\r
qr/^(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-9]*[a-zA-Z0-9]|[a-zA-Z])[.]?)|(?:[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+)))(?::(?:(?:[0-9]*)))?(?:\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9\-_.!~*'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*)(?:\/(?:(?:(?:[a-zA-Z0-9\-_.!~*'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)(?:;(?:(?:[a-zA-Z0-9\-_.!~*'():@&=+$,]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*))*))*))(?:[?](?:(?:(?:[;\/?:@&=+$,a-zA-Z0-9\-_.!~*'()]+|(?:%[a-fA-F0-9][a-fA-F0-9]))*)))?))?)$/
},
'virtualHost' => {
'test' => sub { "DUMMY" }
'test' => sub {
1;
}
}
};
}
......@@ -436,8 +499,15 @@ qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-
'type' => 'keyTextContainer'
},
'grantSessionRules' => {
'keyTest' => sub { "DUMMY" },
'type' => 'grantContainer'
'keyTest' => sub {
my $s = eval {
do {
$_[0];
}
};
return $@ ? ( 0, "__badExpression__: $@" ) : 1;
},
'type' => 'grantContainer'
},
'groups' => {
'default' => {},
......@@ -481,7 +551,7 @@ qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-
'type' => 'bool'
},
'issuerDBOpenIDConnectActivation' => {
'default' => '0',
'default' => 0,
'type' => 'bool'
},
'issuerDBOpenIDConnectPath' => {
......@@ -605,8 +675,17 @@ qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-
},
'ldapServer' => {
'default' => 'ldap://localhost',
'test' => sub { "DUMMY" },
'type' => 'text'
'test' => sub {
my $l = shift();
my (@s) = split( /[\s,]+/, $l, 0 );
foreach my $s (@s) {
return 0, qq[Bad ldap uri "$s"]
unless $s =~
m[^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?::\d{1,5})?/?.*)$]o;
}
return 1;
},
'type' => 'text'
},
'ldapSetPassword' => {
'default' => 0,
......@@ -879,19 +958,19 @@ qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-
'type' => 'int'
},
'oidcServiceAllowAuthorizationCodeFlow' => {
'default' => '1',
'default' => 1,
'type' => 'bool'
},
'oidcServiceAllowDynamicRegistration' => {
'default' => '0',
'default' => 0,
'type' => 'bool'
},
'oidcServiceAllowHybridFlow' => {
'default' => '0',
'default' => 0,
'type' => 'bool'
},
'oidcServiceAllowImplicitFlow' => {
'default' => '0',
'default' => 0,
'type' => 'bool'
},
'oidcServiceKeyIdSig' => {
......
......@@ -52,6 +52,8 @@ $Data::Dumper::Sortkeys = sub {
];
};
$Data::Dumper::Deparse = 1;
sub run {
my $self = shift;
$self = $module->new(@_) unless ref $self;
......@@ -184,8 +186,7 @@ EOF
: ()
} keys(%$attributes)
};
my $defaultAttr = Dumper($defaultValues);
$defaultAttr =~ s/^\$VAR1\s*=/sub defaultValues {\n return/;
my $defaultAttr = mydump($defaultValues,'defaultValues');
$defaultAttr = "# This file is generated by $module. Don't modify it by hand
package Lemonldap::NG::Common::Conf::DefaultValues;
......@@ -223,11 +224,9 @@ $defaultAttr}
( $_ => {@r} );
} keys(%$attributes)
};
$managerAttr = Dumper($managerAttr);
$managerAttr =~ s/^\$VAR1\s*=/sub attributes {\n return/;
$managerAttr = mydump($managerAttr,'attributes');
my $managerTypes =
Dumper( Lemonldap::NG::Manager::Build::Attributes::types() );
$managerTypes =~ s/^\$VAR1\s*=/sub types {\n return/;
mydump( Lemonldap::NG::Manager::Build::Attributes::types(),'types' );
$managerAttr = "# This file is generated by $module. Don't modify it by hand
package Lemonldap::NG::Manager::Attributes;
......@@ -252,6 +251,14 @@ $managerAttr}
print STDERR "done\n";
}
sub mydump {
my ($obj, $subname) = splice @_;
my $t = Dumper($obj);
$t =~ s/^\s*(?:use strict;|package .*?;|)\n//gm;
$t =~ s/^\$VAR1\s*=/sub $subname {\n return/;
return $t;
}
sub scanTree {
my ( $self, $tree, $json, $prefix, $path ) = splice @_;
unless ( ref($tree) eq 'ARRAY' ) {
......@@ -391,7 +398,144 @@ system.
=head1 DESCRIPTION
Lemonldap::NG::Manager::Build is used only to build javascript files and
Lemonldap::NG constants Perl files
Lemonldap::NG constants Perl files. It has to be launched after each change.
=head2 DEVELOPPER CORNER
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);
=item refresh files using this (or launch any build makefile target at the
root of the Lemonldap::NG project sources).
=back
See below for details.
=head3 Attribute declaration
Set your new attribute as a key of attributes() function that points to a hash
ref containing:
=over
=item type (required):
the type of the content. It must be declared in sub
types() in the same file (except if attribute embeds its own tests) and must
correspond to a form stored in the static/forms/ directory;
=item help (optional):
the relative HTML path to the help page (relative to
/doc/pages/documentation/<version>/);
=item default (recommended):
a default value to set if not defined;
=item select (optional):
required only if type is `select`. In this case, it
must contains an array of { k => <keyName>, v => <display name> } hashref
=item documentation (recommended):
some words for other developpers
=item test (optional):
if test is not defined for this type or if test must
be more restrictive, set her a regular expression or a subroutine. Arguments
passed to subroutine are (keyValue, newConf, currentKey), it returns 2
arguments: a boolean result and a message (if non empty will be displayed as
warning or error depending of result);
=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):
for keys/values attributes, test to be applied on
key;
=item keyMsgFail (optional):
for regexp based key tests, same as msgFail for
keys test;
=back
If you decide to declare a new type, you have to declare the following
properties:
=over
=item test, msgFail, keyTest, keyMsgFail as shown above,
=item form: the form to use if it doesn't have the same name.
=back
=head3 Tree positioning
The tree is now very simple: it contains nodes and leaf. Leaf are designed only
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:
must never be used in conjunction with nodes. Array of leafs only
to be displayed in the same form
=item nodes_cond:
array of sub nodes that will be displayed with a filter. Not
yet documented here, see the source code of site/static/js/filterFunctions.js.
=item nodes_filter:
filter entry in site/static/js/filterFunctions.js for the same feature.
=back
=head1 SEE ALSO
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment