make tidy

This commit is contained in:
Xavier Guimard 2018-07-05 23:00:40 +02:00
parent b2620c2679
commit 0f7b3ca71d
38 changed files with 95 additions and 80 deletions

View File

@ -744,8 +744,7 @@ sub metadata {
}
else {
$self->logger->info(
"REST request to get configuration metadata ($res->{cfgNum})"
);
"REST request to get configuration metadata ($res->{cfgNum})" );
}
return $self->sendJSONresponse( $req, $res );
}

View File

@ -33,7 +33,7 @@ sub new {
$self->env->{PATH_INFO} ||= '/';
$self->{uri} = uri_unescape( $self->env->{REQUEST_URI} );
$self->{uri} =~ s|^//+|/|g;
$self->{data} = {};
$self->{data} = {};
$self->{error} = 0;
$self->{respHeaders} = [];
return bless( $self, $_[0] );

View File

@ -405,8 +405,7 @@ sub postUrlInit {
$class->buildSub($sub) )
{
$class->tsv->{maintenance}->{$vhost} = 1;
$class->logger->error(
"$class: Unable to build post data: "
$class->logger->error( "$class: Unable to build post data: "
. $class->tsv->{jail}->error );
}

View File

@ -1457,7 +1457,7 @@ sub attributes {
grep { $_ =~ /Undefined subroutine/ ? () : $_ }
split( /\n/, $@ ) );
return $err ? ( 1, "__badExpression__: $err" ) : (1);
}
}
},
documentation => 'Virtualhost headers',
flags => 'h',

View File

@ -376,7 +376,8 @@ sub diff {
my @cfgNum =
( scalar( $req->param('conf1') ), scalar( $req->param('conf2') ) );
my @conf;
$self->logger->debug(" Loading confs");
$self->logger->debug(" Loading confs");
# Load the 2 configurations
for ( my $i = 0 ; $i < 2 ; $i++ ) {
if ( %{ $self->currentConf }

View File

@ -145,8 +145,7 @@ sub getStack {
my ( $self, $req, @steps ) = @_;
return $req->data->{combinationStack}
if ( $req->data->{combinationStack} );
my $stack = $req->data->{combinationStack} =
$self->stackSub->( $req->env );
my $stack = $req->data->{combinationStack} = $self->stackSub->( $req->env );
unless ($stack) {
$self->logger->error('No authentication scheme for this user');
}

View File

@ -35,8 +35,8 @@ sub extractFormInfo {
my ( $self, $req ) = @_;
if ( $req->data->{_krbUser} ) {
$self->logger->debug( 'Kerberos ticket already validated for '
. $req->data->{_krbUser} );
$self->logger->debug(
'Kerberos ticket already validated for ' . $req->data->{_krbUser} );
return PE_OK;
}

View File

@ -151,7 +151,11 @@ sub extractFormInfo {
my $check_url = $claimed_identity->check_url(
return_to => $self->conf->{portal}
. '?openid=1&'
. ( $req->data->{_url} ? build_urlencoded( url => $req->data->{_url} ) : '' ),
. (
$req->data->{_url}
? build_urlencoded( url => $req->data->{_url} )
: ''
),
trust_root => $self->conf->{portal},
delayed_return => 1,
);

View File

@ -753,7 +753,7 @@ sub extractFormInfo {
my $res = $self->p->deleteSession($req);
return (
$res eq PE_LOGOUT_OK ? PE_SENDRESPONSE : $res );
}
}
]
);

View File

@ -166,9 +166,11 @@ sub ssoMatch {
my ( $self, $req ) = @_;
my $url = $self->normalize_url( $req->uri, $self->conf->{issuerDBSAMLPath},
$self->ssoGetUrl );
return ( $url =~ $self->ssoUrlRe or $req->data->{_proxiedRequest}
? 1
: 0);
return (
$url =~ $self->ssoUrlRe or $req->data->{_proxiedRequest}
? 1
: 0
);
}
# Main method (launched only for authenticated users, see Main/Issuer)

View File

@ -24,13 +24,13 @@ has availableModules => ( is => 'rw', default => sub { {} } );
# to each enabled underlying auth modules
sub betweenAuthAndData { '_betweenAuthAndData' }
sub afterData { '_afterData' }
sub forAuthUser { '_forAuthUser' }
sub beforeLogout { '_beforeLogout' }
sub forAuthUser { '_forAuthUser' }
sub beforeLogout { '_beforeLogout' }
sub _betweenAuthAndData { _wrapEntryPoint( @_, 'betweenAuthAndData' ); }
sub _afterData { _wrapEntryPoint( @_, 'afterData' ); }
sub _forAuthUser { _wrapEntryPoint( @_, 'forAuthUser', 1 ); }
sub _beforeLogout { _wrapEntryPoint( @_, 'beforeLogout', 1 ); }
sub _forAuthUser { _wrapEntryPoint( @_, 'forAuthUser', 1 ); }
sub _beforeLogout { _wrapEntryPoint( @_, 'beforeLogout', 1 ); }
sub _wrapEntryPoint {
my ( $self, $req, $name, $connected ) = @_;

View File

@ -105,7 +105,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}
@ -115,7 +115,6 @@ sub display {
);
}
# 1.3 There is a message to display
elsif ( my $info = $req->info ) {
$self->logger->debug('Display: info detected');

View File

@ -161,8 +161,7 @@ sub deleteSession {
# TODO
# Collect logout services and build hidden iFrames
if ( $req->data->{logoutServices} and %{ $req->data->{logoutServices} } )
{
if ( $req->data->{logoutServices} and %{ $req->data->{logoutServices} } ) {
$self->logger->debug("Create iFrames to forward logout to services");

View File

@ -88,8 +88,8 @@ sub login {
return $self->do(
$req,
[
'controlUrl', @{ $self->beforeAuth },
$self->authProcess, @{ $self->betweenAuthAndData },
'controlUrl', @{ $self->beforeAuth },
$self->authProcess, @{ $self->betweenAuthAndData },
$self->sessionData, @{ $self->afterData },
]
);
@ -100,8 +100,8 @@ sub postLogin {
return $self->do(
$req,
[
'restoreArgs', 'controlUrl',
@{ $self->beforeAuth }, $self->authProcess,
'restoreArgs', 'controlUrl',
@{ $self->beforeAuth }, $self->authProcess,
@{ $self->betweenAuthAndData }, $self->sessionData,
@{ $self->afterData },
]
@ -114,7 +114,7 @@ sub authenticatedRequest {
$req,
[
'importHandlerData', 'controlUrl',
'checkLogout', @{ $self->forAuthUser }
'checkLogout', @{ $self->forAuthUser }
]
);
}
@ -125,7 +125,7 @@ sub postAuthenticatedRequest {
$req,
[
'importHandlerData', 'restoreArgs',
'controlUrl', 'checkLogout',
'controlUrl', 'checkLogout',
@{ $self->forAuthUser }
]
);

View File

@ -13,7 +13,7 @@ extends 'Lemonldap::NG::Common::Module';
# INTERFACE
use constant afterData => 'changeUrldc';
use constant afterData => 'changeUrldc';
use constant forAuthUser => 'changeUrldc';
sub init { 1 }

View File

@ -488,8 +488,7 @@ sub display {
DISPLAY_PASSWORD_FORM => 0,
);
if ( $req->data->{mailToken}
and !$self->p->checkXSSAttack( 'mail_token', $req->data->{mailToken} )
)
and !$self->p->checkXSSAttack( 'mail_token', $req->data->{mailToken} ) )
{
$tplPrm{MAIL_TOKEN} = $req->data->{mailToken};
}

View File

@ -398,8 +398,9 @@ sub display {
STARTMAILDATE => $req->data->{startMailDate},
STARTMAILTIME => $req->data->{startMailTime},
MAILALREADYSENT => $req->data->{mail_already_sent},
MAIL => $self->p->checkXSSAttack( 'mail',
$req->data->{registerInfo}->{mail} ) ? ""
MAIL => $self->p->checkXSSAttack(
'mail', $req->data->{registerInfo}->{mail}
) ? ""
: $req->data->{registerInfo}->{mail},
FIRSTNAME => $self->p->checkXSSAttack( 'firstname',
$req->data->{registerInfo}->{firstname} ) ? ""

View File

@ -38,8 +38,8 @@ sub createUser {
);
if ( $mesg->is_error ) {
$self->userLogger->error( "Can not create entry for "
. $req->data->{registerInfo}->{login} );
$self->userLogger->error(
"Can not create entry for " . $req->data->{registerInfo}->{login} );
$self->logger->error( "LDAP error " . $mesg->error );
$self->ldap->unbind();

View File

@ -67,8 +67,8 @@ sub createUser {
);
if ( $mesg->is_error ) {
$self->userLogger->error( "Can not create entry for "
. $req->data->{registerInfo}->{login} );
$self->userLogger->error(
"Can not create entry for " . $req->data->{registerInfo}->{login} );
$self->logger->error( "LDAP error " . $mesg->error );
$self->ldap->unbind();

View File

@ -57,7 +57,7 @@ SKIP: {
or explain( $res->[1],
'Set-Cookie => lemonldapidp=0; domain=.sp.com; path=/; expires=-1d' );
( $host, $url, $query ) = expectForm( $res, undef, undef, 'confirm', );
my $spPdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $spPdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Choose SAML issuer
$query .= '&idp=http%3A%2F%2Fauth.idp.com%2Fsaml%2Fmetadata';
@ -70,7 +70,7 @@ SKIP: {
),
'Post SAML choice'
);
$spPdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
$spPdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
ok( expectCookie( $res, 'lemonldapidp' ), 'IDP cookie defined' )
or explain(
$res->[1],
@ -92,7 +92,7 @@ SKIP: {
'Post SAML request to IdP'
);
expectOK($res);
my $pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Try to authenticate to IdP
$query = "user=french&password=french&$query";

View File

@ -109,7 +109,7 @@ SKIP: {
'Launch SAML request to IdP'
);
expectOK($res);
my $pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Try to authenticate to IdP
my $body = $res->[2]->[0];

View File

@ -92,7 +92,7 @@ SKIP: {
'Post SAML request to IdP'
);
expectOK($res);
my $pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Try to authenticate to IdP
$s = "user=french&password=french&$s";

View File

@ -87,7 +87,7 @@ SKIP: {
'Launch SAML request to IdP'
);
expectOK($res);
my $pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Try to authenticate to IdP
my $body = $res->[2]->[0];

View File

@ -92,7 +92,7 @@ SKIP: {
'Post SAML request to IdP'
);
expectOK($res);
my $pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Try to authenticate to IdP
$s = "user=french&password=french&$s";

View File

@ -87,7 +87,7 @@ SKIP: {
'Launch SAML request to IdP'
);
expectOK($res);
my $pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Try to authenticate to IdP with unautorizated user
my $body = $res->[2]->[0];

View File

@ -87,7 +87,7 @@ ok(
);
count(1);
expectOK($res);
my $pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Try to authenticate to IdP
my $body = $res->[2]->[0];

View File

@ -89,7 +89,7 @@ ok(
);
count(1);
expectOK($res);
my $pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Try to authenticate to IdP
my $body = $res->[2]->[0];

View File

@ -88,9 +88,8 @@ ok(
'Query CAS server'
);
count(1);
my $pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my ($query) =
expectRedirection( $res, qr#^http://auth.sp.com/# );
my $pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
my ($query) = expectRedirection( $res, qr#^http://auth.sp.com/# );
# Back to SP
switch ('sp');

View File

@ -87,7 +87,7 @@ ok(
);
count(1);
expectOK($res);
my $pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Try to authenticate to IdP
my $body = $res->[2]->[0];

View File

@ -177,7 +177,7 @@ SKIP: {
),
'Query CAS server (2)'
);
$pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
$pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Verify that confirmation is asked
my ( $host, $url );
@ -196,7 +196,7 @@ SKIP: {
'Post confirm'
);
( $host, $url, $query ) = expectForm( $res, undef, undef, 'upgrading' );
$pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
$pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Try to authenticate
$query =~ s/&?password=//;

View File

@ -107,7 +107,7 @@ SKIP: {
"Push request to OP, endpoint $url" );
my ( $host, $tmp );
( $host, $tmp, $query ) = expectForm($res);
my $pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Try to authenticate to OP
$query =~ s/user=&?//;

View File

@ -90,7 +90,7 @@ SKIP: {
'Follow redirection to IdP' );
expectOK($res);
my ($tmp);
my $pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
( $host, $tmp, $query ) = expectForm( $res, '#', undef );
$query .= '&user=dwho&password=dwho';

View File

@ -111,7 +111,7 @@ SKIP: {
ok( $res = $op->_get( $url, query => $query, accept => 'text/html' ),
"Push request to OP, endpoint $url" );
expectOK($res);
my $pdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $pdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Try to authenticate to IdP
$query = "user=french&password=french&$query";

View File

@ -119,8 +119,8 @@ SKIP: {
),
"Push request to OP, endpoint $url"
);
my $spPdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my ($host,$tmp);
my $spPdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
my ( $host, $tmp );
( $host, $tmp, $query ) = expectForm( $res, '#', undef, 'confirm' );
ok(
$res = $sp->_post(
@ -147,7 +147,7 @@ SKIP: {
),
'Launch SAML request to IdP'
);
my $idpPdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $idpPdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
my $tmp;
# Try to authenticate to IdP
@ -197,7 +197,7 @@ SKIP: {
query => $query,
accept => 'text/html',
cookie =>
"lemonldap=$spId;lemonldapidp=http://auth.idp.com/saml/metadata;$spPdata"
"lemonldap=$spId;lemonldapidp=http://auth.idp.com/saml/metadata;$spPdata"
),
'Follow internal redirection from SAML-SP to OIDC-OP'
);
@ -208,7 +208,7 @@ SKIP: {
query => $query,
accept => 'text/html',
cookie =>
"lemonldap=$spId;lemonldapidp=http://auth.idp.com/saml/metadata;$spPdata"
"lemonldap=$spId;lemonldapidp=http://auth.idp.com/saml/metadata;$spPdata"
),
'Confirm OIDC sharing'
);

View File

@ -137,7 +137,7 @@ SKIP: {
( $url, $query ) =
expectRedirection( $res,
qr#http://auth.op.com(/oauth2/authorize)\?(.*)$# );
my $proxyPdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $proxyPdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Push request to OP
switch ('op');
@ -145,7 +145,7 @@ SKIP: {
"Push request to OP, endpoint $url" );
count(1);
expectOK($res);
my $opPdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $opPdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Try to authenticate to OP
$query = "user=french&password=french&$query";
@ -181,12 +181,20 @@ SKIP: {
# Push OP response to Proxy
switch ('proxy');
ok( $res = $proxy->_get( '/', query => $query, accept => 'text/html', cookie => $proxyPdata ),
'Call openidconnectcallback on Proxy' );
ok(
$res = $proxy->_get(
'/',
query => $query,
accept => 'text/html',
cookie => $proxyPdata
),
'Call openidconnectcallback on Proxy'
);
count(1);
my $proxyId = expectCookie($res);
($url,$query) = expectRedirection( $res,
( $url, $query ) = expectRedirection( $res,
qr#http://auth.proxy.com(/saml[^\?]*)(?:\?(.+))?$# );
#$proxyPdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
ok(

View File

@ -132,7 +132,7 @@ SKIP: {
),
'Post SAML request to IdP'
);
my $proxyPdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $proxyPdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
ok( expectCookie( $res, 'llngcasserver' ) eq 'idp',
'Get CAS server cookie' );
($query) = expectRedirection( $res,
@ -149,9 +149,8 @@ qr'^http://auth.idp.com/cas/login\?(service=http%3A%2F%2Fauth.proxy.com%2F.*)$'
),
'Query CAS server'
);
my $idpPdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
( $host, $url, $query ) =
expectForm( $res );
my $idpPdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
( $host, $url, $query ) = expectForm($res);
$query =~ s/&?user=//;
# Try to authenticate to IdP

View File

@ -134,7 +134,7 @@ SKIP: {
),
'Launch SAML request to IdP'
);
my $proxyPdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $proxyPdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
( $url, $query ) =
expectRedirection( $res,
qr#http://auth.op.com(/oauth2/authorize)\?(.*)$# );
@ -145,7 +145,7 @@ SKIP: {
"Push request to OP, endpoint $url" );
count(1);
expectOK($res);
my $opPdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
my $opPdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
# Try to authenticate to OP
$query = "user=french&password=french&$query";
@ -181,13 +181,20 @@ SKIP: {
# Push OP response to Proxy
switch ('proxy');
ok( $res = $proxy->_get( '/', query => $query, accept => 'text/html', cookie => $proxyPdata ),
'Call openidconnectcallback on Proxy' );
ok(
$res = $proxy->_get(
'/',
query => $query,
accept => 'text/html',
cookie => $proxyPdata
),
'Call openidconnectcallback on Proxy'
);
count(1);
my $proxyId = expectCookie($res);
($url,$query) = expectRedirection( $res,
( $url, $query ) = expectRedirection( $res,
qr#http://auth.proxy.com(/saml[^\?]*)(?:\?(.+))?$# );
$proxyPdata = 'lemonldappdata=' . expectCookie($res, 'lemonldappdata');
$proxyPdata = 'lemonldappdata=' . expectCookie( $res, 'lemonldappdata' );
ok(
$res = $proxy->_get(

View File

@ -6,12 +6,12 @@ use Lemonldap::NG::Portal::Main::Constants qw(PE_OK);
extends 'Lemonldap::NG::Portal::Main::Plugin';
sub init {1}
sub init { 1 }
use constant beforeAuth => 'insert';
sub insert {
my($self,$req) = @_;
my ( $self, $req ) = @_;
$req->pdata->{mytest} ||= 0;
$req->pdata->{mytest}++;
return PE_OK;