Commit 62d5c783 authored by Xavier Guimard's avatar Xavier Guimard

make tidy

parent 84e137b8
......@@ -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;
}
......
......@@ -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 {
......
......@@ -21,7 +21,7 @@ ok(
cookieName => 'lemonldap',
securedCookie => 0,
https => 0,
userLogger => 'Lemonldap::NG::Common::Logger::Null',
userLogger => 'Lemonldap::NG::Common::Logger::Null',
}
),
'initialization'
......
......@@ -29,7 +29,7 @@ sub init {
cookieName => 'lemonldap',
securedCookie => 0,
https => 0,
logger => 'Lemonldap::NG::Common::Logger::Std',
logger => 'Lemonldap::NG::Common::Logger::Std',
%$prms
);
ok(
......
......@@ -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
# )
# );
#}
}
......
......@@ -68,7 +68,7 @@ has confChanged => (
);
# Properties required during build
has refConf => ( is => 'ro', isa => 'HashRef', required => 1 );
has refConf => ( is => 'ro', isa => 'HashRef', required => 1 );
has req => ( is => 'ro', required => 1 );
has newConf => ( is => 'rw', isa => 'HashRef' );
has tree => ( is => 'rw', isa => 'ArrayRef' );
......@@ -157,7 +157,7 @@ sub _scanNodes {
hdebug("Looking to $name");
# subnode
my $subNodes = $leaf->{nodes} // $leaf->{_nodes};
my $subNodes = $leaf->{nodes} // $leaf->{_nodes};
my $subNodesCond = $leaf->{nodes_cond} // $leaf->{_nodes_cond};
##################################
......@@ -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] )
{
......@@ -1051,15 +1051,15 @@ sub _unitTest {
or $attr->{type} =~ /Container$/ )
{
my $keyMsg = $attr->{keyMsgFail} // $type->{keyMsgFail};
my $msg = $attr->{msgFail} // $type->{msgFail};
my $msg = $attr->{msgFail} // $type->{msgFail};
$res = 0
unless (
$self->_execTest(
{
keyTest => $attr->{keyTest} // $type->{keyTest},
keyTest => $attr->{keyTest} // $type->{keyTest},
keyMsgFail => $attr->{keyMsgFail}
// $type->{keyMsgFail},
test => $attr->{test} // $type->{test},
test => $attr->{test} // $type->{test},
msgFail => $attr->{msgFail} // $type->{msgFail},
},
$conf->{$key},
......
......@@ -40,14 +40,14 @@ sub addRoutes {
['DELETE']
)
# DELETE OIDC CONSENT
->addRoute(
# DELETE OIDC CONSENT
->addRoute(
sessions => {
OIDCConsent =>
{ ':sessionType' => { ':sessionId' => 'delOIDCConsent' } }
},
['DELETE']
);
);
$self->setTypes($conf);
......
......@@ -24,7 +24,7 @@ delete $forms{restore};
my ( @types, $attr, $tree, $ctrees );
ok( $tree = Lemonldap::NG::Manager::Build::Tree::tree(), 'Get tree' );
ok( $ctrees = Lemonldap::NG::Manager::Build::CTrees::cTrees(), 'Get cTrees' );
ok( $attr = Lemonldap::NG::Manager::Build::Attributes::attributes(),
ok( $attr = Lemonldap::NG::Manager::Build::Attributes::attributes(),
'Get attributes' );
$count += 4;
......
......@@ -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]");
......@@ -132,17 +132,25 @@ for ( my $i = 1 ; $i < 6 ; $i++ ) {
and $res->{uid} =~ /^(?:dwho|rtyler|msmith|davros|tof)$/
),
'Persistent sessions with UID found'
);
);
}
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
......
......@@ -103,7 +103,7 @@ sub init {
# Enable REST request only if more than 1 2F module is enabled
if ( @{ $self->{sfModules} } > 1 ) {
$self->addUnauthRoute( '2fchoice' => '_choice', ['POST'] );
$self->addUnauthRoute( '2fchoice' => '_choice', ['POST'] );
$self->addUnauthRoute( '2fchoice' => '_redirect', ['GET'] );
}
......
......@@ -67,7 +67,7 @@ sub run {
my $TOTPName = $req->param('TOTPName');
my $epoch = time();
# Set default name if empty, check characters and truncate name if too long
# Set default name if empty, check characters and truncate name if too long
$TOTPName ||= $epoch;
unless ( $TOTPName =~ /^[\w]+$/ ) {
$self->userLogger->error('TOTP name with bad character(s)');
......
......@@ -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();
}
......
......@@ -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()
......@@ -79,9 +80,9 @@ 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("Prepare U2F verification");
$self->logger->debug( " -> Send challenge: " . $data->{challenge} );
# Serialize data
$data = to_json(
{
......@@ -208,7 +209,7 @@ sub loadUser {
return PE_ERROR;
}
$self->logger->debug("2F Device(s) found");
$self->logger->debug("Looking for registered U2F key(s) ...");
foreach (@$_2fDevices) {
if ( $_->{type} eq 'U2F' ) {
......
......@@ -34,7 +34,7 @@ sub init {
$self->logger->error($@);
return 0;
}
# If self registration is enabled and "activation" is just set to
# "enabled", replace the rule to detect if user has registered its key
if ( $self->conf->{yubikey2fSelfRegistration}
......
......@@ -16,7 +16,7 @@ extends 'Lemonldap::NG::Portal::Main::Auth',
# INTERFACE
has opList => ( is => 'rw', default => sub { [] } );
has opList => ( is => 'rw', default => sub { [] } );
has opNumber => ( is => 'rw', default => 0 );
has path => ( is => 'rw', default => 'oauth2' );
......
......@@ -754,7 +754,7 @@ sub extractFormInfo {
my $res = $self->p->deleteSession($req);
return (
$res eq PE_LOGOUT_OK ? PE_SENDRESPONSE : $res );
}
}
]
);
......
......@@ -41,8 +41,8 @@ sub init {
"Unable to load configuration: $Lemonldap::NG::Common::Conf::msg");
return 0;
}
$lconf->{$_} = $args->{$_} foreach ( keys %$args );
$conf->{$_} = $lconf->{$_} foreach ( keys %$lconf );
$lconf->{$_} = $args->{$_} foreach ( keys %$args );
$conf->{$_} = $lconf->{$_} foreach ( keys %$lconf );
$self->SUPER::init($lconf) or return 0;
$self->cdc_name( $conf->{samlCommonDomainCookieName} || '_saml_idp' );
$self->cdc_domain( $conf->{samlCommonDomainCookieDomain} );
......
......@@ -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
......
......@@ -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 {
......
......@@ -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
......
......@@ -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
......
......@@ -110,7 +110,7 @@ sub getToken {
return undef;
}
my %h = %{ $tsession->{data} };
$tsession->remove unless($keep);
$tsession->remove unless ($keep);
return \%h;
}
}
......
......@@ -174,7 +174,7 @@ sub send_mail {
foreach ( keys %cid ) {
$message->attach(
Type => "image/" . ( $cid{$_} =~ m/\.(\w+)/ )[0],
Id => $_,
Id => $_,
Path => $self->p->{templateDir} . "/" . $cid{$_},
);
}
......
......@@ -106,7 +106,7 @@ sub display {
&& $req->data->{login},
ASK_LOGINS => $req->param('checkLogins') || 0,
CONFIRMKEY => $self->stamp(),
LIST => $req->data->{list} || [],
LIST => $req->data->{list} || [],
REMEMBER => $req->data->{confirmRemember},
(
$req->data->{customScript}
......@@ -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};
}
}
......
......@@ -32,7 +32,7 @@ sub createUser {
givenName => $gn,
unicodePwd => utf8(
chr(34) . $req->data->{registerInfo}->{password} . chr(34)
)->utf16le(),
)->utf16le(),
mail => $req->data->{registerInfo}->{mail},
]
);
......
......@@ -7,11 +7,13 @@ sub new {
unless ( $self->{conf}->{customRegister} ) {
die 'Custom register module not defined';
}
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;
......@@ -292,6 +292,7 @@ ok(
);
count(1);
$idpId = expectCookie($res);
#expectRedirection( $res, qr#^http://auth.rp.com/# );
#print STDERR Dumper($res);
......
......@@ -20,7 +20,7 @@ SKIP: {
);
$dbh->prepare(
q{INSERT INTO notifications VALUES ('dwho','testref','2016-05-30 00:00:00',?,null,null)}
)->execute(
)->execute(
'[
{
"uid": "dwho",
......@@ -32,7 +32,7 @@ q{INSERT INTO notifications VALUES ('dwho','testref','2016-05-30 00:00:00',?,nul
"check": ["Accept test"]
}
]'
);
);
my $client = LLNG::Manager::Test->new(
{
......
......@@ -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,
),
......
......@@ -81,7 +81,7 @@ SKIP: {
my $code;
ok( $code = Lemonldap::NG::Common::TOTP::_code( undef, $key, 0, 30, 8 ),
'Code' );
ok( $code =~ /^\d{8}$/, 'Code contains 8 digits' );
ok( $code =~ /^\d{8}$/, 'Code contains 8 digits' );
my $s = "code=$code&token=$token";
ok(
$res = $client->_post(
......@@ -110,19 +110,18 @@ SKIP: {
);
my ( $host, $url, $query ) =
expectForm( $res, undef, '/totp2fcheck', 'token' );
# Generate TOTP with LLNG
my $totp;
ok( $totp = Lemonldap::NG::Common::TOTP::_code( undef, $key, 0, 30, 8 ),
'LLNG Code' );
# 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(
$res = $client->_post(
......
......@@ -11,12 +11,12 @@ SKIP: {
if ($@) {
skip 'Convert::Base32 is missing', $maintests;
}
eval { require Crypt::U2F::Server; require Authen::U2F::Tester };
if ( $@ or $Crypt::U2F::Server::VERSION < 0.42 ) {
skip 'Missing libraries', $maintests;
}
require Lemonldap::NG::Common::TOTP;
my $client = LLNG::Manager::Test->new(
......
......@@ -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);
......@@ -370,7 +369,7 @@ sub _get {
: ()
),
'REQUEST_METHOD' => $args{method} || 'GET',
'REQUEST_URI' => $path . ( $args{query} ? "?$args{query}" : '' ),
'REQUEST_URI' => $path . ( $args{query} ? "?$args{query}" : '' ),
( $args{query} ? ( QUERY_STRING => $args{query} ) : () ),
'SCRIPT_NAME' => '',
'SERVER_NAME' => 'auth.example.com',
......@@ -406,10 +405,10 @@ sub _post {
: ()
),
'REQUEST_METHOD' => $args{method} || 'POST',
'REQUEST_URI' => $path . ( $args{query} ? "?$args{query}" : '' ),
'SCRIPT_NAME' => '',
'SERVER_NAME' => 'auth.example.com',
'SERVER_PORT' => '80',
'REQUEST_URI' => $path . ( $args{query} ? "?$args{query}" : '' ),
'SCRIPT_NAME' => '',
'SERVER_NAME' => 'auth.example.com',
'SERVER_PORT' => '80',
'SERVER_PROTOCOL' => 'HTTP/1.1',
( $args{custom} ? %{ $args{custom} } : () ),
'psgix.input.buffered' => 0,
......
......@@ -53,7 +53,7 @@ sub mirror {
: ()
),
'REQUEST_METHOD' => $args{method} || 'GET',
'REQUEST_URI' => ( $args{path} || '/' )
'REQUEST_URI' => ( $args{path} || '/' )
. ( $args{query} ? "?$args{query}" : '' ),
( $args{query} ? ( QUERY_STRING => $args{query} ) : () ),
'SCRIPT_NAME' => '',
......
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