Commit c7b4eb50 authored by Xavier Guimard's avatar Xavier Guimard

tidy with new conf

parent 2532970b
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
--nobreak-before-all-operators --nobreak-before-all-operators
--blanks-before-comments --blanks-before-comments
--nocuddled-else --nocuddled-else
--maximum-line-length=79 --maximum-line-length=80
--paren-tightness=1 --paren-tightness=1
--square-bracket-tightness=1 --square-bracket-tightness=1
--space-for-semicolon --space-for-semicolon
......
...@@ -9,9 +9,7 @@ our $VERSION = '2.0.0'; ...@@ -9,9 +9,7 @@ our $VERSION = '2.0.0';
has confAccess => ( has confAccess => (
is => 'rw', is => 'rw',
builder => sub { builder => sub {
my $res = Lemonldap::NG::Common::Conf->new( my $res = Lemonldap::NG::Common::Conf->new( { (
{
(
ref $_[0] && $_[0]->{iniFile} ref $_[0] && $_[0]->{iniFile}
? ( confFile => $_[0]->{iniFile} ) ? ( confFile => $_[0]->{iniFile} )
: () : ()
......
...@@ -13,8 +13,7 @@ has app => ( is => 'ro', isa => 'CodeRef' ); ...@@ -13,8 +13,7 @@ has app => ( is => 'ro', isa => 'CodeRef' );
sub _get { sub _get {
my ( $self, $path, $query ) = @_; my ( $self, $path, $query ) = @_;
$query //= ''; $query //= '';
return $self->app->( return $self->app->( {
{
'HTTP_ACCEPT' => 'application/json, text/plain, */*', 'HTTP_ACCEPT' => 'application/json, text/plain, */*',
'SCRIPT_NAME' => '', 'SCRIPT_NAME' => '',
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
...@@ -39,8 +38,7 @@ sub _post { ...@@ -39,8 +38,7 @@ sub _post {
my ( $self, $path, $query, $body, $type, $len ) = @_; my ( $self, $path, $query, $body, $type, $len ) = @_;
die "$body must be a IO::Handle" die "$body must be a IO::Handle"
unless ( ref($body) and $body->can('read') ); unless ( ref($body) and $body->can('read') );
return $self->app->( return $self->app->( {
{
'HTTP_ACCEPT' => 'application/json, text/plain, */*', 'HTTP_ACCEPT' => 'application/json, text/plain, */*',
'SCRIPT_NAME' => '', 'SCRIPT_NAME' => '',
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
...@@ -69,8 +67,7 @@ sub _put { ...@@ -69,8 +67,7 @@ sub _put {
my ( $self, $path, $query, $body, $type, $len ) = @_; my ( $self, $path, $query, $body, $type, $len ) = @_;
die "$body must be a IO::Handle" die "$body must be a IO::Handle"
unless ( ref($body) and $body->can('read') ); unless ( ref($body) and $body->can('read') );
return $self->app->( return $self->app->( {
{
'HTTP_ACCEPT' => 'application/json, text/plain, */*', 'HTTP_ACCEPT' => 'application/json, text/plain, */*',
'SCRIPT_NAME' => '', 'SCRIPT_NAME' => '',
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
...@@ -97,8 +94,7 @@ sub _put { ...@@ -97,8 +94,7 @@ sub _put {
sub _del { sub _del {
my ( $self, $path, $query ) = @_; my ( $self, $path, $query ) = @_;
return $self->app->( return $self->app->( {
{
'HTTP_ACCEPT' => 'application/json, text/plain, */*', 'HTTP_ACCEPT' => 'application/json, text/plain, */*',
'SCRIPT_NAME' => '', 'SCRIPT_NAME' => '',
'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
......
...@@ -239,8 +239,7 @@ sub session { ...@@ -239,8 +239,7 @@ sub session {
sub getApacheSession { sub getApacheSession {
my ( $self, $mod, $id, $info, $force ) = @_; my ( $self, $mod, $id, $info, $force ) = @_;
my $apacheSession = Lemonldap::NG::Common::Session->new( my $apacheSession = Lemonldap::NG::Common::Session->new( {
{
storageModule => $mod->{module}, storageModule => $mod->{module},
storageModuleOptions => $mod->{options}, storageModuleOptions => $mod->{options},
cacheModule => cacheModule =>
......
...@@ -17,8 +17,7 @@ my $h; ...@@ -17,8 +17,7 @@ my $h;
my $inifile = "lemonldap-ng.ini"; my $inifile = "lemonldap-ng.ini";
my $confsection = "configuration"; my $confsection = "configuration";
ok( ok( (
(
Lemonldap::NG::Common::Conf->new( type => 'bad' ) == 0 Lemonldap::NG::Common::Conf->new( type => 'bad' ) == 0
and $Lemonldap::NG::Common::Conf::msg =~ and $Lemonldap::NG::Common::Conf::msg =~
/Error: Unknown package Lemonldap::NG::Common::Conf::Backends::bad\.$/ /Error: Unknown package Lemonldap::NG::Common::Conf::Backends::bad\.$/
...@@ -28,8 +27,7 @@ ok( ...@@ -28,8 +27,7 @@ ok(
$h = bless {}, 'Lemonldap::NG::Common::Conf'; $h = bless {}, 'Lemonldap::NG::Common::Conf';
ok( ok( (
(
%$h = ( %$h, %{ $h->getLocalConf( $confsection, $inifile, 0 ) } ) %$h = ( %$h, %{ $h->getLocalConf( $confsection, $inifile, 0 ) } )
and exists $h->{localStorage} and exists $h->{localStorage}
), ),
......
...@@ -17,8 +17,7 @@ BEGIN { use_ok('Lemonldap::NG::Common::Conf') } ...@@ -17,8 +17,7 @@ BEGIN { use_ok('Lemonldap::NG::Common::Conf') }
my $h; my $h;
ok( ok(
$h = new Lemonldap::NG::Common::Conf( $h = new Lemonldap::NG::Common::Conf( {
{
type => 'File', type => 'File',
dirName => "t/", dirName => "t/",
} }
......
...@@ -27,8 +27,7 @@ SKIP: { ...@@ -27,8 +27,7 @@ SKIP: {
my $skipSQLite = 0; my $skipSQLite = 0;
ok( ok(
$h = new Lemonldap::NG::Common::Conf( $h = new Lemonldap::NG::Common::Conf( {
{
type => 'CDBI', type => 'CDBI',
dbiChain => "DBI:SQLite:dbname=t/lmConf.sql", dbiChain => "DBI:SQLite:dbname=t/lmConf.sql",
dbiUser => '', dbiUser => '',
......
...@@ -27,8 +27,7 @@ SKIP: { ...@@ -27,8 +27,7 @@ SKIP: {
my $skipSQLite = 0; my $skipSQLite = 0;
ok( ok(
$h = new Lemonldap::NG::Common::Conf( $h = new Lemonldap::NG::Common::Conf( {
{
type => 'RDBI', type => 'RDBI',
dbiChain => "DBI:SQLite:dbname=t/lmConf.sql", dbiChain => "DBI:SQLite:dbname=t/lmConf.sql",
dbiUser => '', dbiUser => '',
......
...@@ -18,8 +18,7 @@ SKIP: { ...@@ -18,8 +18,7 @@ SKIP: {
use_ok('Lemonldap::NG::Common::Conf'); use_ok('Lemonldap::NG::Common::Conf');
my $h; my $h;
ok( ok(
$h = new Lemonldap::NG::Common::Conf( $h = new Lemonldap::NG::Common::Conf( {
{
type => 'LDAP', type => 'LDAP',
ldapServer => 'ldap://localhost', ldapServer => 'ldap://localhost',
ldapConfBase => 'ou=conf,ou=websso,dc=example,dc=com', ldapConfBase => 'ou=conf,ou=websso,dc=example,dc=com',
......
...@@ -23,8 +23,7 @@ my $sessionOptions = { ...@@ -23,8 +23,7 @@ my $sessionOptions = {
LockDirectory => $dir, LockDirectory => $dir,
}; };
my $session = Lemonldap::NG::Common::Session->new( my $session = Lemonldap::NG::Common::Session->new( {
{
storageModule => $sessionModule, storageModule => $sessionModule,
storageModuleOptions => $sessionOptions, storageModuleOptions => $sessionOptions,
kind => "TEST", kind => "TEST",
...@@ -43,8 +42,7 @@ use_ok('Lemonldap::NG::Common::Apache::Session::Generate::SHA256'); ...@@ -43,8 +42,7 @@ use_ok('Lemonldap::NG::Common::Apache::Session::Generate::SHA256');
$sessionOptions->{generateModule} = $sessionOptions->{generateModule} =
"Lemonldap::NG::Common::Apache::Session::Generate::SHA256"; "Lemonldap::NG::Common::Apache::Session::Generate::SHA256";
my $session2 = Lemonldap::NG::Common::Session->new( my $session2 = Lemonldap::NG::Common::Session->new( {
{
storageModule => $sessionModule, storageModule => $sessionModule,
storageModuleOptions => $sessionOptions, storageModuleOptions => $sessionOptions,
kind => "TEST", kind => "TEST",
......
...@@ -161,8 +161,7 @@ our $_ua; ...@@ -161,8 +161,7 @@ our $_ua;
sub ua { sub ua {
my ($class) = @_; my ($class) = @_;
return $_ua if ($_ua); return $_ua if ($_ua);
$_ua = Lemonldap::NG::Common::UserAgent->new( $_ua = Lemonldap::NG::Common::UserAgent->new( {
{
lwpOpts => $class->localConfig->{lwpOpts}, lwpOpts => $class->localConfig->{lwpOpts},
lwpSslOpts => $class->localConfig->{lwpSslOpts} lwpSslOpts => $class->localConfig->{lwpSslOpts}
} }
......
...@@ -59,8 +59,7 @@ sub getCDAInfos { ...@@ -59,8 +59,7 @@ sub getCDAInfos {
my $infos = {}; my $infos = {};
# Get the session # Get the session
my $cdaSession = Lemonldap::NG::Common::Session->new( my $cdaSession = Lemonldap::NG::Common::Session->new( {
{
storageModule => $class->tsv->{sessionStorageModule}, storageModule => $class->tsv->{sessionStorageModule},
storageModuleOptions => $class->tsv->{sessionStorageOptions}, storageModuleOptions => $class->tsv->{sessionStorageOptions},
cacheModule => $class->tsv->{sessionCacheModule}, cacheModule => $class->tsv->{sessionCacheModule},
......
...@@ -37,8 +37,7 @@ sub loadVhostConfig { ...@@ -37,8 +37,7 @@ sub loadVhostConfig {
my $json; my $json;
if ( $class->tsv->{useSafeJail} ) { if ( $class->tsv->{useSafeJail} ) {
my $rUrl = $req->{env}->{RULES_URL} my $rUrl = $req->{env}->{RULES_URL}
|| ( || ( (
(
$class->localConfig->{loopBackUrl} $class->localConfig->{loopBackUrl}
|| "http://127.0.0.1:" . $req->{env}->{SERVER_PORT} || "http://127.0.0.1:" . $req->{env}->{SERVER_PORT}
) )
......
...@@ -178,8 +178,7 @@ sub configReload { ...@@ -178,8 +178,7 @@ sub configReload {
sub jailInit { sub jailInit {
my ( $class, $conf ) = @_; my ( $class, $conf ) = @_;
$class->tsv->{jail} = Lemonldap::NG::Handler::Main::Jail->new( $class->tsv->{jail} = Lemonldap::NG::Handler::Main::Jail->new( {
{
useSafeJail => $conf->{useSafeJail}, useSafeJail => $conf->{useSafeJail},
customFunctions => $conf->{customFunctions}, customFunctions => $conf->{customFunctions},
} }
...@@ -193,8 +192,7 @@ sub jailInit { ...@@ -193,8 +192,7 @@ sub jailInit {
sub defaultValuesInit { sub defaultValuesInit {
my ( $class, $conf ) = @_; my ( $class, $conf ) = @_;
$class->tsv->{$_} = $conf->{$_} foreach ( $class->tsv->{$_} = $conf->{$_} foreach ( qw(
qw(
cookieExpiration cookieName customFunctions httpOnly cookieExpiration cookieName customFunctions httpOnly
securedCookie timeout timeoutActivity securedCookie timeout timeoutActivity
timeoutActivityInterval useRedirectOnError useRedirectOnForbidden timeoutActivityInterval useRedirectOnError useRedirectOnForbidden
......
...@@ -446,8 +446,7 @@ sub retrieveSession { ...@@ -446,8 +446,7 @@ sub retrieveSession {
# 2. Get the session from cache or backend # 2. Get the session from cache or backend
my $session = $req->data->{session} = ( my $session = $req->data->{session} = (
Lemonldap::NG::Common::Session->new( Lemonldap::NG::Common::Session->new( {
{
storageModule => $class->tsv->{sessionStorageModule}, storageModule => $class->tsv->{sessionStorageModule},
storageModuleOptions => $class->tsv->{sessionStorageOptions}, storageModuleOptions => $class->tsv->{sessionStorageOptions},
cacheModule => $class->tsv->{sessionCacheModule}, cacheModule => $class->tsv->{sessionCacheModule},
......
...@@ -30,8 +30,7 @@ eval { Lemonldap::NG::Handler::Main->logLevelInit('error') }; ...@@ -30,8 +30,7 @@ eval { Lemonldap::NG::Handler::Main->logLevelInit('error') };
ok( !$@, 'logLevelInit' ); ok( !$@, 'logLevelInit' );
ok( ok(
Lemonldap::NG::Handler::Main->jailInit( Lemonldap::NG::Handler::Main->jailInit( {
{
https => 0, https => 0,
port => 0, port => 0,
maintenance => 0, maintenance => 0,
...@@ -51,8 +50,7 @@ ok( ...@@ -51,8 +50,7 @@ ok(
); );
ok( ok(
Lemonldap::NG::Handler::Main->defaultValuesInit( Lemonldap::NG::Handler::Main->defaultValuesInit( {
{
https => 0, https => 0,
port => 0, port => 0,
maintenance => 0, maintenance => 0,
...@@ -72,8 +70,7 @@ ok( ...@@ -72,8 +70,7 @@ ok(
); );
ok( ok(
Lemonldap::NG::Handler::Main->locationRulesInit( Lemonldap::NG::Handler::Main->locationRulesInit( {
{
'locationRules' => { 'locationRules' => {
'www1' => { 'www1' => {
'default' => 'accept', 'default' => 'accept',
......
...@@ -13,8 +13,7 @@ ok( $app = module( Lemonldap::NG::Handler::PSGI::Try->new() ), 'New object' ); ...@@ -13,8 +13,7 @@ ok( $app = module( Lemonldap::NG::Handler::PSGI::Try->new() ), 'New object' );
init(); init();
ok( ok(
$app->init( $app->init( {
{
configStorage => { type => 'File', dirName => 't' }, configStorage => { type => 'File', dirName => 't' },
localSessionStorage => '', localSessionStorage => '',
logLevel => 'warn', logLevel => 'warn',
......
...@@ -105,8 +105,7 @@ sub _get { ...@@ -105,8 +105,7 @@ sub _get {
my ( $self, $path, $query, $host, $cookie, %custom ) = @_; my ( $self, $path, $query, $host, $cookie, %custom ) = @_;
$query //= ''; $query //= '';
$host ||= 'test1.example.com'; $host ||= 'test1.example.com';
return $self->app->( return $self->app->( {
{
'HTTP_ACCEPT' => 'text/html', 'HTTP_ACCEPT' => 'text/html',
'SCRIPT_NAME' => 'lmAuth', 'SCRIPT_NAME' => 'lmAuth',
'SERVER_NAME' => '127.0.0.1', 'SERVER_NAME' => '127.0.0.1',
......
...@@ -269,8 +269,7 @@ $defaultAttr} ...@@ -269,8 +269,7 @@ $defaultAttr}
foreach ( @simpleHashKeys, @doubleHashKeys, sort keys %cnodesRe ) { foreach ( @simpleHashKeys, @doubleHashKeys, sort keys %cnodesRe ) {
$ra->add($_); $ra->add($_);
} }
foreach ( foreach ( qw(
qw(
exportedHeaders locationRules post vhostOptions exportedHeaders locationRules post vhostOptions
samlIDPMetaDataXML samlIDPMetaDataExportedAttributes samlIDPMetaDataXML samlIDPMetaDataExportedAttributes
samlIDPMetaDataOptions samlSPMetaDataXML samlIDPMetaDataOptions samlSPMetaDataXML
...@@ -462,8 +461,7 @@ sub scanTree { ...@@ -462,8 +461,7 @@ sub scanTree {
$jleaf->{"_$n"} = []; $jleaf->{"_$n"} = [];
$self->scanTree( $leaf->{$n}, $jleaf->{"_$n"}, $prefix, $self->scanTree( $leaf->{$n}, $jleaf->{"_$n"}, $prefix,
"$path.$nodeName\[$ord\]" ); "$path.$nodeName\[$ord\]" );
if ( if ( (
(
$leaf->{title} eq 'authParams' $leaf->{title} eq 'authParams'
and $n eq 'nodes_cond' and $n eq 'nodes_cond'
) )
......
...@@ -2944,8 +2944,7 @@ m{^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?: ...@@ -2944,8 +2944,7 @@ m{^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?:
keyTest => qr/^(\d*)?[a-zA-Z0-9_]+$/, keyTest => qr/^(\d*)?[a-zA-Z0-9_]+$/,
keyMsgFail => '__badChoiceKey__', keyMsgFail => '__badChoiceKey__',
test => sub { 1 }, test => sub { 1 },
select => [ select => [ [
[
{ k => 'Apache', v => 'Apache' }, { k => 'Apache', v => 'Apache' },
{ k => 'AD', v => 'Active Directory' }, { k => 'AD', v => 'Active Directory' },
{ {
......
...@@ -103,8 +103,7 @@ sub cTrees { ...@@ -103,8 +103,7 @@ sub cTrees {
{ {
title => "samlSPMetaDataOptions", title => "samlSPMetaDataOptions",
help => 'idpsaml.html#options', help => 'idpsaml.html#options',
nodes => [ nodes => [ {
{
title => "samlSPMetaDataOptionsAuthnResponse", title => "samlSPMetaDataOptionsAuthnResponse",
form => 'simpleInputContainer', form => 'simpleInputContainer',
nodes => [ nodes => [
...@@ -144,8 +143,7 @@ sub cTrees { ...@@ -144,8 +143,7 @@ sub cTrees {
'oidcOPMetaDataExportedVars', 'oidcOPMetaDataExportedVars',
{ {
title => 'oidcOPMetaDataOptions', title => 'oidcOPMetaDataOptions',
nodes => [ nodes => [ {
{
title => 'oidcOPMetaDataOptionsConfiguration', title => 'oidcOPMetaDataOptionsConfiguration',
form => 'simpleInputContainer', form => 'simpleInputContainer',
nodes => [ nodes => [
...@@ -187,8 +185,7 @@ sub cTrees { ...@@ -187,8 +185,7 @@ sub cTrees {
'oidcRPMetaDataExportedVars', 'oidcRPMetaDataExportedVars',
{ {
title => 'oidcRPMetaDataOptions', title => 'oidcRPMetaDataOptions',
nodes => [ nodes => [ {
{
title => 'oidcRPMetaDataOptionsAuthentication', title => 'oidcRPMetaDataOptionsAuthentication',
form => 'simpleInputContainer', form => 'simpleInputContainer',
nodes => [ nodes => [
...@@ -225,8 +222,7 @@ sub cTrees { ...@@ -225,8 +222,7 @@ sub cTrees {
}, },
'oidcRPMetaDataOptionsExtraClaims', 'oidcRPMetaDataOptionsExtraClaims',
], ],
casSrvMetaDataNode => [ casSrvMetaDataNode => [ {
{
title => 'casSrvMetaDataOptions', title => 'casSrvMetaDataOptions',
form => 'simpleInputContainer', form => 'simpleInputContainer',
nodes => [ nodes => [
...@@ -240,8 +236,7 @@ sub cTrees { ...@@ -240,8 +236,7 @@ sub cTrees {
'casSrvMetaDataExportedVars', 'casSrvMetaDataExportedVars',
'casSrvMetaDataOptionsProxiedServices', 'casSrvMetaDataOptionsProxiedServices',
], ],
casAppMetaDataNode => [ casAppMetaDataNode => [ {
{
title => 'casAppMetaDataOptions', title => 'casAppMetaDataOptions',
form => 'simpleInputContainer', form => 'simpleInputContainer',
nodes => [ nodes => [
......
...@@ -24,11 +24,9 @@ our $VERSION = '2.0.2'; ...@@ -24,11 +24,9 @@ our $VERSION = '2.0.2';
# * confirmFormMethod # * confirmFormMethod
# * redirectFormMethod # * redirectFormMethod
sub tree { sub tree {
return [ return [ {
{
title => 'generalParameters', title => 'generalParameters',
nodes => [ nodes => [ {
{
title => 'portalParams', title => 'portalParams',
help => 'portal.html', help => 'portal.html',
nodes => [ nodes => [
...@@ -36,8 +34,7 @@ sub tree { ...@@ -36,8 +34,7 @@ sub tree {
{ {
title => 'portalMenu', title => 'portalMenu',
help => 'portalmenu.html', help => 'portalmenu.html',
nodes => [ nodes => [ {
{
title => 'portalModules', title => 'portalModules',
form => 'simpleInputContainer', form => 'simpleInputContainer',
nodes => [ nodes => [
...@@ -119,8 +116,7 @@ sub tree { ...@@ -119,8 +116,7 @@ sub tree {
nodes => [ nodes => [
'authentication', 'userDB', 'passwordDB', 'registerDB' 'authentication', 'userDB', 'passwordDB', 'registerDB'
], ],
nodes_cond => [ nodes_cond => [ {
{
title => 'adParams', title => 'adParams',
help => 'authad.html', help => 'authad.html',
form => 'simpleInputContainer', form => 'simpleInputContainer',
...@@ -152,8 +148,7 @@ sub tree { ...@@ -152,8 +148,7 @@ sub tree {
{ {
title => 'dbiConnection', title => 'dbiConnection',
help => 'authdbi.html#connection', help => 'authdbi.html#connection',
nodes => [ nodes => [ {
{
title => 'dbiConnectionAuth', title => 'dbiConnectionAuth',
form => 'simpleInputContainer', form => 'simpleInputContainer',
nodes => [ nodes => [
...@@ -427,8 +422,7 @@ sub tree { ...@@ -427,8 +422,7 @@ sub tree {
{ {
title => 'issuerParams', title => 'issuerParams',
help => 'start.html#identity_provider', help => 'start.html#identity_provider',
nodes => [ nodes => [ {
{
title => 'issuerDBSAML', title => 'issuerDBSAML',
help => 'idpsaml.html', help => 'idpsaml.html',
form => 'simpleInputContainer', form => 'simpleInputContainer',
...@@ -601,8 +595,7 @@ sub tree { ...@@ -601,8 +595,7 @@ sub tree {
{ {
title => 'passwordManagement', title => 'passwordManagement',
help => 'resetpassword.html', help => 'resetpassword.html',
nodes => [ nodes => [ {
{
title => 'mailContent', title => 'mailContent',
form => 'simpleInputContainer', form => 'simpleInputContainer',
nodes => [ nodes => [
...@@ -649,8 +642,7 @@ sub tree { ...@@ -649,8 +642,7 @@ sub tree {
{ {
title => 'secondFactors', title => 'secondFactors',
help => 'secondfactor.html', help => 'secondfactor.html',
nodes => [ nodes => [ {
{
title => 'utotp2f', title => 'utotp2f',
help => 'utotp2f.html', help => 'utotp2f.html',
form => 'simpleInputContainer',