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',
......
...@@ -274,9 +274,7 @@ sub attributes { ...@@ -274,9 +274,7 @@ sub attributes {
'authChoiceModules' => { 'authChoiceModules' => {
'keyMsgFail' => '__badChoiceKey__', 'keyMsgFail' => '__badChoiceKey__',
'keyTest' => qr/^(\d*)?[a-zA-Z0-9_]+$/, 'keyTest' => qr/^(\d*)?[a-zA-Z0-9_]+$/,
'select' => [ 'select' => [ [ {
[
{
'k' => 'Apache', 'k' => 'Apache',
'v' => 'Apache' 'v' => 'Apache'
}, },
...@@ -373,8 +371,7 @@ sub attributes { ...@@ -373,8 +371,7 @@ sub attributes {
'v' => 'customModule' 'v' => 'customModule'
} }
], ],
[ [ {
{
'k' => 'AD', 'k' => 'AD',
'v' => 'Active Directory' 'v' => 'Active Directory'
}, },
...@@ -439,8 +436,7 @@ sub attributes { ...@@ -439,8 +436,7 @@ sub attributes {
'v' => 'customModule' 'v' => 'customModule'
} }
], ],
[ [ {
{
'k' => 'AD', 'k' => 'AD',
'v' => 'Active Directory' 'v' => 'Active Directory'
}, },
...@@ -481,8 +477,7 @@ sub attributes { ...@@ -481,8 +477,7 @@ sub attributes {
}, },
'authentication' => { 'authentication' => {
'default' => 'Demo', 'default' => 'Demo',
'select' => [ 'select' => [ {
{
'k' => 'Apache', 'k' => 'Apache',
'v' => 'Apache' 'v' => 'Apache'
}, },
...@@ -637,8 +632,7 @@ sub attributes { ...@@ -637,8 +632,7 @@ sub attributes {
}, },
'casAccessControlPolicy' => { 'casAccessControlPolicy' => {
'default' => 'none', 'default' => 'none',
'select' => [ 'select' => [ {
{
'k' => 'none', 'k' => 'none',
'v' => 'None' 'v' => 'None'
}, },
...@@ -782,8 +776,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.] ...@@ -782,8 +776,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
}, },
'combModules' => { 'combModules' => {
'keyTest' => qr/^\w+$/, 'keyTest' => qr/^\w+$/,
'select' => [ 'select' => [ {
{
'k' => 'Apache', 'k' => 'Apache',
'v' => 'Apache' 'v' => 'Apache'
}, },
...@@ -886,8 +879,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.] ...@@ -886,8 +879,7 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
}, },
'confirmFormMethod' => { 'confirmFormMethod' => {
'default' => 'post', 'default' => 'post',
'select' => [ 'select' => [ {
{
'k' => 'get', 'k' => 'get',
'v' => 'GET' 'v' => 'GET'
}, },
...@@ -1185,8 +1177,7 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][ ...@@ -1185,8 +1177,7 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
}, },
'infoFormMethod' => { 'infoFormMethod' => {
'default' => 'get', 'default' => 'get',
'select' => [ 'select' => [ {
{
'k' => 'get', 'k' => 'get',
'v' => 'GET' 'v' => 'GET'
}, },
...@@ -1392,8 +1383,7 @@ qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0- ...@@ -1392,8 +1383,7 @@ qr/^(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-zA-Z0-
}, },
'ldapSearchDeref' => { 'ldapSearchDeref' => {
'default' => 'find', 'default' => 'find',
'select' => [ 'select' => [ {
{
'k' => 'never', 'k' => 'never',
'v' => 'never' 'v' => 'never'
}, },
...@@ -1750,8 +1740,7 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][ ...@@ -1750,8 +1740,7 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
}, },
'oidcOPMetaDataOptionsDisplay' => { 'oidcOPMetaDataOptionsDisplay' => {
'default' => '', 'default' => '',
'select' => [ 'select' => [ {
{
'k' => '', 'k' => '',