Commit 286af2cf authored by Christophe Maudoux's avatar Christophe Maudoux 🐛

Merge branch 'v2.0' into code-refactoring-v2

parents 92854c2f 0a4fabb4
Pipeline #10047 passed with stage
in 19 minutes and 37 seconds
...@@ -13,7 +13,7 @@ use JSON::XS; ...@@ -13,7 +13,7 @@ use JSON::XS;
#use AutoLoader qw(AUTOLOAD); #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. # Set here all the names of functions that must be available in Safe objects.
# Not that only functions, not methods, can be written here # Not that only functions, not methods, can be written here
...@@ -65,8 +65,8 @@ sub checkLogonHours { ...@@ -65,8 +65,8 @@ sub checkLogonHours {
# Use time_correction # Use time_correction
if ($time_correction) { if ($time_correction) {
my ( $sign, $time ) = ( $time_correction =~ /([+|-]?)(\d+)/ ); my ( $sign, $time ) = ( $time_correction =~ /([+|-]?)(\d+)/ );
if ( $sign =~ /-/ ) { $hourpos -= $time; } if ( $sign =~ /-/ ) { $hourpos -= $time; }
else { $hourpos += $time; } else { $hourpos += $time; }
} }
# Get the corresponding byte # Get the corresponding byte
...@@ -229,29 +229,22 @@ my $json = JSON::XS->new; ...@@ -229,29 +229,22 @@ my $json = JSON::XS->new;
sub has2f { sub has2f {
my ( $session, $type ) = @_; my ( $session, $type ) = @_;
unless ( $session->{_2fDevices} ) { return 0 unless ( $session->{_2fDevices} );
return 0;
} my $_2fDevices = eval { $json->decode( $session->{_2fDevices} ); };
my $_2fDevices; return 0 if ( $@ or ref($_2fDevices) ne "ARRAY" );
eval { $_2fDevices = $json->decode( $session->{_2fDevices} ); };
if ( $@ or ref($_2fDevices) ne "ARRAY" ) { my $length = scalar @{$_2fDevices};
return 0;
}
# Empty array # Empty array
if ( length @{$_2fDevices} == 0 ) { return 0 unless $length;
return 0;
# Array has one value and we did not specify a type, succeed # Array has one value and we did not specify a type, succeed
} if ($type) {
elsif ( not $type ) {
return 1;
}
else {
my @found = grep { lc( $_->{type} ) eq lc($type) } @{$_2fDevices}; my @found = grep { lc( $_->{type} ) eq lc($type) } @{$_2fDevices};
return ( @found ? 1 : 0 ); return ( @found ? 1 : 0 );
} }
return 0; return 1;
} }
1; 1;
...@@ -11,11 +11,13 @@ use Lemonldap::NG::Common::Conf::ReConstants; ...@@ -11,11 +11,13 @@ use Lemonldap::NG::Common::Conf::ReConstants;
#use feature 'state'; #use feature 'state';
extends 'Lemonldap::NG::Manager::Plugin', extends qw(
'Lemonldap::NG::Common::Conf::AccessLib', Lemonldap::NG::Manager::Plugin
'Lemonldap::NG::Common::Session::REST'; Lemonldap::NG::Common::Session::REST
Lemonldap::NG::Common::Conf::AccessLib
);
our $VERSION = '2.0.9'; our $VERSION = '2.0.10';
############################# #############################
# I. INITIALIZATION METHODS # # I. INITIALIZATION METHODS #
......
package Lemonldap::NG::Manager::Api::Common; package Lemonldap::NG::Manager::Api::Common;
our $VERSION = '2.0.9'; our $VERSION = '2.0.10';
package Lemonldap::NG::Manager::Api; package Lemonldap::NG::Manager::Api;
use strict;
use Lemonldap::NG::Manager::Build::Attributes; use Lemonldap::NG::Manager::Build::Attributes;
use Lemonldap::NG::Manager::Build::CTrees; use Lemonldap::NG::Manager::Build::CTrees;
...@@ -26,7 +27,7 @@ sub _getDefaultValues { ...@@ -26,7 +27,7 @@ sub _getDefaultValues {
my $defaultAttrs = Lemonldap::NG::Manager::Build::Attributes::attributes(); my $defaultAttrs = Lemonldap::NG::Manager::Build::Attributes::attributes();
my $attrs = {}; my $attrs = {};
foreach $attr (@allAttrs) { foreach my $attr (@allAttrs) {
$attrs->{$attr} = $defaultAttrs->{$attr}->{default} $attrs->{$attr} = $defaultAttrs->{$attr}->{default}
if ( defined $defaultAttrs->{$attr} if ( defined $defaultAttrs->{$attr}
&& defined $defaultAttrs->{$attr}->{default} ); && defined $defaultAttrs->{$attr}->{default} );
...@@ -39,7 +40,7 @@ sub _hasAllowedAttributes { ...@@ -39,7 +40,7 @@ sub _hasAllowedAttributes {
my ( $self, $attributes, $rootNode ) = @_; my ( $self, $attributes, $rootNode ) = @_;
my @allowedAttributes = $self->_listAttributes($rootNode); my @allowedAttributes = $self->_listAttributes($rootNode);
foreach $attribute ( keys %{$attributes} ) { foreach my $attribute ( keys %{$attributes} ) {
if ( length( ref($attribute) ) ) { if ( length( ref($attribute) ) ) {
return { return {
res => "ko", res => "ko",
......
package Lemonldap::NG::Manager::Conf::Tests; package Lemonldap::NG::Manager::Conf::Tests;
use strict;
use utf8; use utf8;
use strict; use strict;
use Lemonldap::NG::Common::Regexp; use Lemonldap::NG::Common::Regexp;
...@@ -450,7 +451,7 @@ sub tests { ...@@ -450,7 +451,7 @@ sub tests {
"RSA_SHA1" ) "RSA_SHA1" )
{ {
undef $allsha1; undef $allsha1;
break; last;
} }
} }
} }
...@@ -462,7 +463,7 @@ sub tests { ...@@ -462,7 +463,7 @@ sub tests {
->{samlSPMetaDataOptionsSignatureMethod} ne "RSA_SHA1" ) ->{samlSPMetaDataOptionsSignatureMethod} ne "RSA_SHA1" )
{ {
undef $allsha1; undef $allsha1;
break; last;
} }
} }
} }
...@@ -866,8 +867,7 @@ sub tests { ...@@ -866,8 +867,7 @@ sub tests {
$appUrl =~ m#^(https?://[^/]+)(/.*)?$#; $appUrl =~ m#^(https?://[^/]+)(/.*)?$#;
my $appHost = $1; my $appHost = $1;
unless ($appHost) { unless ($appHost) {
push @msg, push @msg, "$casConfKey CAS Application has no Service URL";
"$clientConfKey CAS Application has no Service URL";
$res = 0; $res = 0;
next; next;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# of lemonldap-ng.ini) and underlying handler configuration # of lemonldap-ng.ini) and underlying handler configuration
package Lemonldap::NG::Portal::Main::Init; package Lemonldap::NG::Portal::Main::Init;
our $VERSION = '2.0.9'; our $VERSION = '2.0.10';
package Lemonldap::NG::Portal::Main; package Lemonldap::NG::Portal::Main;
...@@ -161,24 +161,24 @@ sub setPortalRoutes { ...@@ -161,24 +161,24 @@ sub setPortalRoutes {
# psgi.js # psgi.js
->addUnauthRoute( 'psgi.js' => 'sendJs', ['GET'] ) ->addUnauthRoute( 'psgi.js' => 'sendJs', ['GET'] )
->addAuthRoute( 'psgi.js' => 'sendJs', ['GET'] ) ->addAuthRoute( 'psgi.js' => 'sendJs', ['GET'] )
# portal.css # portal.css
->addUnauthRoute( 'portal.css' => 'sendCss', ['GET'] ) ->addUnauthRoute( 'portal.css' => 'sendCss', ['GET'] )
->addAuthRoute( 'portal.css' => 'sendCss', ['GET'] ) ->addAuthRoute( 'portal.css' => 'sendCss', ['GET'] )
# lmerror # lmerror
->addUnauthRoute( lmerror => { ':code' => 'lmError' }, ['GET'] ) ->addUnauthRoute( lmerror => { ':code' => 'lmError' }, ['GET'] )
->addAuthRoute( lmerror => { ':code' => 'lmError' }, ['GET'] ) ->addAuthRoute( lmerror => { ':code' => 'lmError' }, ['GET'] )
# Core REST API # Core REST API
->addUnauthRoute( ping => 'pleaseAuth', ['GET'] ) ->addUnauthRoute( ping => 'pleaseAuth', ['GET'] )
->addAuthRoute( ping => 'authenticated', ['GET'] ) ->addAuthRoute( ping => 'authenticated', ['GET'] )
# Refresh session # Refresh session
->addAuthRoute( refresh => 'refresh', ['GET'] ) ->addAuthRoute( refresh => 'refresh', ['GET'] )
->addAuthRoute( '*' => 'corsPreflight', ['OPTIONS'] ) ->addAuthRoute( '*' => 'corsPreflight', ['OPTIONS'] )
->addUnauthRoute( '*' => 'corsPreflight', ['OPTIONS'] ) ->addUnauthRoute( '*' => 'corsPreflight', ['OPTIONS'] )
# Logout # Logout
...@@ -239,9 +239,11 @@ sub reloadConf { ...@@ -239,9 +239,11 @@ sub reloadConf {
# Initialize templateDir # Initialize templateDir
$self->{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} ) { 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; return $self->fail;
} }
$self->templateDir( $self->templateDir(
......
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