diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Safelib.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Safelib.pm index 165b5621e054b3fcc9cf7362f7978f907e980013..3104c8997959ff859ee09c796341ac9b8c2febc3 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Safelib.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Safelib.pm @@ -13,7 +13,7 @@ use JSON::XS; #use AutoLoader qw(AUTOLOAD); -our $VERSION = '2.0.7'; +our $VERSION = '2.0.10'; # Set here all the names of functions that must be available in Safe objects. # Not that only functions, not methods, can be written here @@ -65,8 +65,8 @@ sub checkLogonHours { # Use time_correction if ($time_correction) { my ( $sign, $time ) = ( $time_correction =~ /([+|-]?)(\d+)/ ); - if ( $sign =~ /-/ ) { $hourpos -= $time; } - else { $hourpos += $time; } + if ( $sign =~ /-/ ) { $hourpos -= $time; } + else { $hourpos += $time; } } # Get the corresponding byte @@ -229,29 +229,22 @@ my $json = JSON::XS->new; sub has2f { my ( $session, $type ) = @_; - unless ( $session->{_2fDevices} ) { - return 0; - } - my $_2fDevices; - eval { $_2fDevices = $json->decode( $session->{_2fDevices} ); }; - if ( $@ or ref($_2fDevices) ne "ARRAY" ) { - return 0; - } + return 0 unless ( $session->{_2fDevices} ); + + my $_2fDevices = eval { $json->decode( $session->{_2fDevices} ); }; + return 0 if ( $@ or ref($_2fDevices) ne "ARRAY" ); + + my $length = scalar @{$_2fDevices}; # Empty array - if ( length @{$_2fDevices} == 0 ) { - return 0; + return 0 unless $length; - # Array has one value and we did not specify a type, succeed - } - elsif ( not $type ) { - return 1; - } - else { + # Array has one value and we did not specify a type, succeed + if ($type) { my @found = grep { lc( $_->{type} ) eq lc($type) } @{$_2fDevices}; return ( @found ? 1 : 0 ); } - return 0; + return 1; } 1; diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/2ndFA.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/2ndFA.pm index 982023be3701de51fbb6d86ff360ad5c3d40295b..91f682f257bc827801c5290510d117f8642c3576 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/2ndFA.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/2ndFA.pm @@ -11,11 +11,13 @@ use Lemonldap::NG::Common::Conf::ReConstants; #use feature 'state'; -extends 'Lemonldap::NG::Manager::Plugin', - 'Lemonldap::NG::Common::Conf::AccessLib', - 'Lemonldap::NG::Common::Session::REST'; +extends qw( + Lemonldap::NG::Manager::Plugin + Lemonldap::NG::Common::Session::REST + Lemonldap::NG::Common::Conf::AccessLib +); -our $VERSION = '2.0.9'; +our $VERSION = '2.0.10'; ############################# # I. INITIALIZATION METHODS # diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Api/Common.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Api/Common.pm index ea22ca7aa7d0835f0635a35ebcc6ccc9323001a9..5da910b2939a805db524db5fea8cf4f4a97d0a5a 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Api/Common.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Api/Common.pm @@ -1,9 +1,10 @@ package Lemonldap::NG::Manager::Api::Common; -our $VERSION = '2.0.9'; +our $VERSION = '2.0.10'; package Lemonldap::NG::Manager::Api; +use strict; use Lemonldap::NG::Manager::Build::Attributes; use Lemonldap::NG::Manager::Build::CTrees; @@ -26,7 +27,7 @@ sub _getDefaultValues { my $defaultAttrs = Lemonldap::NG::Manager::Build::Attributes::attributes(); my $attrs = {}; - foreach $attr (@allAttrs) { + foreach my $attr (@allAttrs) { $attrs->{$attr} = $defaultAttrs->{$attr}->{default} if ( defined $defaultAttrs->{$attr} && defined $defaultAttrs->{$attr}->{default} ); @@ -39,7 +40,7 @@ sub _hasAllowedAttributes { my ( $self, $attributes, $rootNode ) = @_; my @allowedAttributes = $self->_listAttributes($rootNode); - foreach $attribute ( keys %{$attributes} ) { + foreach my $attribute ( keys %{$attributes} ) { if ( length( ref($attribute) ) ) { return { res => "ko", diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Tests.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Tests.pm index 007630c6e0a6edc279669ba92c347374c71e3f8f..404bf9c88333f2cedb40bc5e742643a461514f4a 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Tests.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf/Tests.pm @@ -1,5 +1,6 @@ package Lemonldap::NG::Manager::Conf::Tests; +use strict; use utf8; use strict; use Lemonldap::NG::Common::Regexp; @@ -450,7 +451,7 @@ sub tests { "RSA_SHA1" ) { undef $allsha1; - break; + last; } } } @@ -462,7 +463,7 @@ sub tests { ->{samlSPMetaDataOptionsSignatureMethod} ne "RSA_SHA1" ) { undef $allsha1; - break; + last; } } } @@ -866,8 +867,7 @@ sub tests { $appUrl =~ m#^(https?://[^/]+)(/.*)?$#; my $appHost = $1; unless ($appHost) { - push @msg, - "$clientConfKey CAS Application has no Service URL"; + push @msg, "$casConfKey CAS Application has no Service URL"; $res = 0; next; } diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm index 67571b77072c4dc2eabd56ba4b90a4a1bb2c6928..57e10d951a789d83d982063c5c89c4ba9a9d6d42 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Init.pm @@ -8,7 +8,7 @@ # of lemonldap-ng.ini) and underlying handler configuration package Lemonldap::NG::Portal::Main::Init; -our $VERSION = '2.0.9'; +our $VERSION = '2.0.10'; package Lemonldap::NG::Portal::Main; @@ -161,24 +161,24 @@ sub setPortalRoutes { # psgi.js ->addUnauthRoute( 'psgi.js' => 'sendJs', ['GET'] ) - ->addAuthRoute( 'psgi.js' => 'sendJs', ['GET'] ) + ->addAuthRoute( 'psgi.js' => 'sendJs', ['GET'] ) # portal.css ->addUnauthRoute( 'portal.css' => 'sendCss', ['GET'] ) - ->addAuthRoute( 'portal.css' => 'sendCss', ['GET'] ) + ->addAuthRoute( 'portal.css' => 'sendCss', ['GET'] ) # lmerror ->addUnauthRoute( lmerror => { ':code' => 'lmError' }, ['GET'] ) - ->addAuthRoute( lmerror => { ':code' => 'lmError' }, ['GET'] ) + ->addAuthRoute( lmerror => { ':code' => 'lmError' }, ['GET'] ) # Core REST API - ->addUnauthRoute( ping => 'pleaseAuth', ['GET'] ) + ->addUnauthRoute( ping => 'pleaseAuth', ['GET'] ) ->addAuthRoute( ping => 'authenticated', ['GET'] ) # Refresh session ->addAuthRoute( refresh => 'refresh', ['GET'] ) - ->addAuthRoute( '*' => 'corsPreflight', ['OPTIONS'] ) + ->addAuthRoute( '*' => 'corsPreflight', ['OPTIONS'] ) ->addUnauthRoute( '*' => 'corsPreflight', ['OPTIONS'] ) # Logout @@ -239,9 +239,11 @@ sub reloadConf { # Initialize templateDir $self->{templateDir} = - $self->conf->{templateDir} . '/' . $self->conf->{portalSkin}; + $self->conf->{templateDir} . '/' . $self->conf->{portalSkin} + if ( $self->conf->{templateDir} and $self->conf->{portalSkin} ); unless ( -d $self->{templateDir} ) { - $self->error("Template dir $self->{templateDir} doesn't exist"); + $self->error("Template dir $self->{templateDir} doesn't exist") + if ref( $self->{templateDir} ) eq 'SCALAR'; return $self->fail; } $self->templateDir(