make tidy

This commit is contained in:
Xavier Guimard 2018-09-02 17:31:58 +02:00
parent 84e137b8c9
commit 62d5c7836c
33 changed files with 92 additions and 82 deletions

View File

@ -47,8 +47,7 @@ sub deleteNotification {
# Check input parameters
unless ( $uid and $myref ) {
$self->userLogger->error(
'REST service "delete notification" called without all parameters'
);
'REST service "delete notification" called without all parameters');
return 0;
}

View File

@ -89,9 +89,7 @@ sub print {
sub addToHtmlHead {
my $self = shift;
$self->logger->error(
'Features like form replay or logout_app can only be used with Apache'
),
;
'Features like form replay or logout_app can only be used with Apache');
}
sub cgiName {

View File

@ -76,9 +76,10 @@ sub del2F {
or return $self->sendError( $req, 'Bad mode', 400 );
my $params = $req->parameters();
my $type = $params->{type} or return $self->sendError( $req, 'Missing "type" parameter', 400 );
my $epoch = $params->{epoch} or return $self->sendError( $req, 'Missing "epoch" parameter', 400 );
my $type = $params->{type}
or return $self->sendError( $req, 'Missing "type" parameter', 400 );
my $epoch = $params->{epoch}
or return $self->sendError( $req, 'Missing "epoch" parameter', 400 );
if ( $type =~ /\b(?:U2F|TOTP|UBK)\b/ ) {
$self->logger->debug(
@ -242,10 +243,13 @@ sub sfa {
$self->logger->debug(
"Removing sessions unless a $_ device is registered");
}
#else {
#(
#return $self->sendError( $req, "Bad or Missing " . $_ . "Check parameter",
#400 ) );
# (
# return $self->sendError(
# $req, "Bad or Missing " . $_ . "Check parameter", 400
# )
# );
#}
}

View File

@ -531,7 +531,7 @@ sub _scanNodes {
: {}
}
);
for ( my $i = 0 ; $i < @listCatNew; $i++ ) {
for ( my $i = 0 ; $i < @listCatNew ; $i++ ) {
if ( not( defined $listCatRef[$i] )
or $listCatRef[$i] ne $listCatNew[$i] )
{

View File

@ -48,6 +48,7 @@ my $res;
## Sessions creation
# SSO session
$ids[0] = newSession( 'dwho', '127.10.0.1', 'SSO', $sfaDevices );
# Peristent sesssions
$ids[1] = newSession( 'msmith', '127.10.0.1', 'Persistent', $sfaDevices );
$sfaDevices = [
@ -115,14 +116,13 @@ $sfaDevices = [
];
$ids[5] = newSession( 'tof', '127.10.0.1', 'Persistent', $sfaDevices );
## Verify sessions creation
# Single SSO session access
$res = &client->jsonResponse("/sessions/global/$ids[0]");
ok( ( $res->{uid} and $res->{uid} eq 'dwho' ), 'UID found' );
ok( ( $res->{ipAddr} and $res->{ipAddr} eq '127.10.0.1' ), 'IP found' );
count(2);
# Single Persistent sessions access
for ( my $i = 1 ; $i < 6 ; $i++ ) {
$res = &client->jsonResponse("/sessions/persistent/$ids[$i]");
@ -138,11 +138,19 @@ count(5);
## Single Persistent sfa access
$res = &client->jsonResponse("/sfa/persistent/$ids[3]");
ok( ( $res->{uid} and $res->{uid} eq 'dwho' ), 'UID found' ) or print STDERR Dumper($res);
ok( ( $res->{ipAddr} and $res->{ipAddr} eq '127.10.0.1' ), 'IP found' ) or print STDERR Dumper($res);
ok( ( $res->{_2fDevices} and $res->{_2fDevices} =~ /"type":\s*"U2F"/s ), 'U2F found' ) or print STDERR Dumper($res);
ok( ( $res->{_2fDevices} and $res->{_2fDevices} =~ /"type":\s*"TOTP"/s ), 'TOTP found' ) or print STDERR Dumper($res);
ok( ( $res->{_2fDevices} and $res->{_2fDevices} =~ /"type":\s*"UBK"/s ), 'UBK found' ) or print STDERR Dumper($res);
ok( ( $res->{uid} and $res->{uid} eq 'dwho' ), 'UID found' )
or print STDERR Dumper($res);
ok( ( $res->{ipAddr} and $res->{ipAddr} eq '127.10.0.1' ), 'IP found' )
or print STDERR Dumper($res);
ok( ( $res->{_2fDevices} and $res->{_2fDevices} =~ /"type":\s*"U2F"/s ),
'U2F found' )
or print STDERR Dumper($res);
ok( ( $res->{_2fDevices} and $res->{_2fDevices} =~ /"type":\s*"TOTP"/s ),
'TOTP found' )
or print STDERR Dumper($res);
ok( ( $res->{_2fDevices} and $res->{_2fDevices} =~ /"type":\s*"UBK"/s ),
'UBK found' )
or print STDERR Dumper($res);
count(5);
## "All" query

View File

@ -34,7 +34,8 @@ sub init {
if ( $self->conf->{totp2fSelfRegistration}
and $self->conf->{totp2fActivation} eq '1' )
{
$self->conf->{totp2fActivation} = '$_2fDevices && $_2fDevices =~ /"type":\s*"TOTP"/s';
$self->conf->{totp2fActivation} =
'$_2fDevices && $_2fDevices =~ /"type":\s*"TOTP"/s';
}
return $self->SUPER::init();
}

View File

@ -37,7 +37,8 @@ sub init {
if ( $self->conf->{u2fSelfRegistration}
and $self->conf->{u2fActivation} eq '1' )
{
$self->conf->{u2fActivation} = '$_2fDevices && $_2fDevices =~ /"type":\s*"U2F"/s';
$self->conf->{u2fActivation} =
'$_2fDevices && $_2fDevices =~ /"type":\s*"U2F"/s';
}
return 0
unless ( $self->Lemonldap::NG::Portal::Main::SecondFactor::init()
@ -80,7 +81,7 @@ sub run {
$self->ott->updateToken( $token, __ch => $data->{challenge} );
$self->logger->debug("Prepare U2F verification");
$self->logger->debug(" -> Send challenge: ". $data->{challenge});
$self->logger->debug( " -> Send challenge: " . $data->{challenge} );
# Serialize data
$data = to_json(

View File

@ -398,7 +398,7 @@ sub run {
# Read existing RP
@RPoidcConsent = grep { $_->{rp} eq $rp } @$_oidcConsents;
unless ( @RPoidcConsent ) {
unless (@RPoidcConsent) {
$self->logger->debug("No Relying Party $rp Consent found");
# Set default value

View File

@ -778,7 +778,7 @@ sub run {
if ( $method == $self->getHttpMethod("post")
|| $method == $self->getHttpMethod("artifact-post") )
{
$artifact_method = $self->getHttpMethod("artifact-post")
$artifact_method = $self->getHttpMethod("artifact-post");
}
else {

View File

@ -160,8 +160,7 @@ sub getNotifBack {
$self->p->updatePersistentSession( $req,
{ "notification_$reference" => time() } );
$self->logger->debug(
"Notification $reference registered in persistent session"
);
"Notification $reference registered in persistent session");
}
# Notifications accepted for this file, delete it unless it's a wildcard

View File

@ -219,8 +219,7 @@ sub getNotifBack {
$self->p->updatePersistentSession( $req,
{ "notification_$reference" => time() } );
$self->logger->debug(
"Notification $reference registered in persistent session"
);
"Notification $reference registered in persistent session");
}
# Notifications accepted for this file, delete it unless it's a wildcard

View File

@ -110,7 +110,7 @@ sub getToken {
return undef;
}
my %h = %{ $tsession->{data} };
$tsession->remove unless($keep);
$tsession->remove unless ($keep);
return \%h;
}
}

View File

@ -550,7 +550,8 @@ sub mkOidcConsent {
$consents->{$rp}->{epoch} = $_->{epoch};
$consents->{$rp}->{scope} = $_->{scope};
$consents->{$rp}->{displayName} =
$self->conf->{oidcRPMetaDataOptions}->{$rp}->{oidcRPMetaDataOptionsDisplayName};
$self->conf->{oidcRPMetaDataOptions}->{$rp}
->{oidcRPMetaDataOptionsDisplayName};
}
}

View File

@ -10,8 +10,10 @@ sub new {
eval $self->{p}->loadModule( $self->{conf}->{customRegister} );
($@)
? return $self->{p}->loadModule( $self->{conf}->{customRegister )
: die 'Unable to load register module ' . $self->{conf}->{customRegister};
}
? return $self->{p}->loadModule(
$self->{conf}->{ customRegister )
: die 'Unable to load register module '
. $self->{conf}->{customRegister};
}
1;
1;

View File

@ -292,6 +292,7 @@ ok(
);
count(1);
$idpId = expectCookie($res);
#expectRedirection( $res, qr#^http://auth.rp.com/# );
#print STDERR Dumper($res);

View File

@ -50,8 +50,7 @@ ok(
$res = $client->_post(
'/',
IO::String->new(
'user=dwho&password=dwho&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw=='
),
'user=dwho&password=dwho&url=aHR0cDovL3Rlc3QxLmV4YW1wbGUuY29tLw=='),
accept => 'text/html',
length => 64,
),

View File

@ -118,10 +118,9 @@ SKIP: {
# Generate TOTP with an external application to validate LLNG TOTP formula
my $oath = Authen::OATH->new( digits => 8 );
ok( $code = $oath->totp( $key ),
'Ext. App Code' );
ok( $code == $totp, 'Both TOTP match')
or explain( [ $code, $totp ], 'LLNG and Ext. App TOTP mismatch');
ok( $code = $oath->totp($key), 'Ext. App Code' );
ok( $code == $totp, 'Both TOTP match' )
or explain( [ $code, $totp ], 'LLNG and Ext. App TOTP mismatch' );
$query =~ s/code=/code=$code/;
ok(

View File

@ -296,8 +296,7 @@ has ini => (
$ini->{$k} //= $defaultIni->{$k};
}
$self->{ini} = $ini;
main::ok( $self->{p} = $self->class->new(),
'Portal object' );
main::ok( $self->{p} = $self->class->new(), 'Portal object' );
main::ok( $self->{p}->init($ini), 'Init' );
main::ok( $self->{app} = $self->{p}->run(), 'Portal app' );
main::count(3);