Commit 0a4fabb4 authored by Christophe Maudoux's avatar Christophe Maudoux 🐛

Use strict & fix warnings

parent d22bb7bc
Pipeline #10046 passed with stage
in 19 minutes and 28 seconds
......@@ -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;
......@@ -10,14 +10,14 @@
# Sessions.pm to manage sessions
package Lemonldap::NG::Manager;
use 5.10.0;
use strict;
use utf8;
use Mouse;
use JSON;
use Lemonldap::NG::Common::Conf::Constants;
use Lemonldap::NG::Common::PSGI::Constants;
our $VERSION = '2.0.9';
our $VERSION = '2.0.10';
extends 'Lemonldap::NG::Common::Conf::AccessLib',
'Lemonldap::NG::Handler::PSGI::Router';
......
package Lemonldap::NG::Manager::2ndFA;
use 5.10.0;
use utf8;
use strict;
use Mouse;
......@@ -12,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 #
......
# This module implements all the methods that responds to '/api/*' requests
package Lemonldap::NG::Manager::Api;
use 5.10.0;
use strict;
use utf8;
use Mouse;
extends 'Lemonldap::NG::Manager::Plugin',
'Lemonldap::NG::Common::Conf::RESTServer',
'Lemonldap::NG::Common::Session::REST';
extends qw(
Lemonldap::NG::Manager::Plugin
Lemonldap::NG::Common::Session::REST
Lemonldap::NG::Common::Conf::RESTServer
);
use Lemonldap::NG::Manager::Api::2F;
use Lemonldap::NG::Manager::Api::Misc;
......@@ -17,7 +19,7 @@ use Lemonldap::NG::Manager::Api::Providers::CasApp;
use Lemonldap::NG::Manager::Api::Menu::Cat;
use Lemonldap::NG::Manager::Api::Menu::App;
our $VERSION = '2.0.9';
our $VERSION = '2.0.10';
#############################
# I. INITIALIZATION METHODS #
......
package Lemonldap::NG::Manager::Api::2F;
our $VERSION = '2.0.9';
our $VERSION = '2.0.10';
package Lemonldap::NG::Manager::Api;
use 5.10.0;
use strict;
use utf8;
use Mouse;
use JSON;
......
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",
......
package Lemonldap::NG::Manager::Api::Menu::App;
our $VERSION = '2.0.9';
our $VERSION = '2.0.10';
package Lemonldap::NG::Manager::Api;
use 5.10.0;
use strict;
use utf8;
use Mouse;
use Lemonldap::NG::Manager::Conf::Parser;
use Data::Dumper;
extends 'Lemonldap::NG::Manager::Api::Common';
......
package Lemonldap::NG::Manager::Api::Menu::Cat;
our $VERSION = '2.0.9';
our $VERSION = '2.0.10';
package Lemonldap::NG::Manager::Api;
use 5.10.0;
use strict;
use utf8;
use Mouse;
use Lemonldap::NG::Manager::Conf::Parser;
......
# Miscenalleous endpoints
package Lemonldap::NG::Manager::Api::Misc;
our $VERSION = '2.0.9';
our $VERSION = '2.0.10';
package Lemonldap::NG::Manager::Api;
use strict;
use Mouse;
extends 'Lemonldap::NG::Manager::Api::Common';
......
package Lemonldap::NG::Manager::Api::Providers::CasApp;
our $VERSION = '2.0.9';
our $VERSION = '2.0.10';
package Lemonldap::NG::Manager::Api;
use 5.10.0;
use strict;
use utf8;
use Mouse;
use Lemonldap::NG::Manager::Conf::Parser;
......
package Lemonldap::NG::Manager::Api::Providers::OidcRp;
our $VERSION = '2.0.8';
our $VERSION = '2.0.10';
package Lemonldap::NG::Manager::Api;
use 5.10.0;
use strict;
use utf8;
use Mouse;
use Lemonldap::NG::Manager::Conf::Parser;
......
package Lemonldap::NG::Manager::Api::Providers::SamlSp;
our $VERSION = '2.0.8';
our $VERSION = '2.0.10';
package Lemonldap::NG::Manager::Api;
use 5.10.0;
use strict;
use utf8;
use Mouse;
......
......@@ -6,7 +6,7 @@
# Read methods are inherited from Lemonldap::NG::Common::Conf::RESTServer
package Lemonldap::NG::Manager::Conf;
use 5.10.0;
use strict;
use utf8;
use Mouse;
use Lemonldap::NG::Common::Conf::Constants;
......
package Lemonldap::NG::Manager::Conf::Tests;
use strict;
use utf8;
use Lemonldap::NG::Common::Regexp;
use Lemonldap::NG::Handler::Main;
......@@ -449,7 +450,7 @@ sub tests {
"RSA_SHA1" )
{
undef $allsha1;
break;
last;
}
}
}
......@@ -461,7 +462,7 @@ sub tests {
->{samlSPMetaDataOptionsSignatureMethod} ne "RSA_SHA1" )
{
undef $allsha1;
break;
last;
}
}
}
......@@ -865,8 +866,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;
}
......
package Lemonldap::NG::Manager::Notifications;
use 5.10.0;
use strict;
use utf8;
use Mouse;
use JSON qw(from_json to_json);
......
package Lemonldap::NG::Manager::Sessions;
use 5.10.0;
use utf8;
use strict;
use Mouse;
......
package Lemonldap::NG::Manager::Viewer;
use 5.10.0;
use strict;
use utf8;
use Mouse;
use Lemonldap::NG::Common::Conf::Constants;
......
......@@ -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(
......
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