Commit 80f5d06e authored by dcoutadeur dcoutadeur's avatar dcoutadeur dcoutadeur

perl tidy

parent 6533b0a3
......@@ -212,7 +212,9 @@ sub getConf {
# Create cipher object
unless ( $args->{raw} ) {
eval { $res->{cipher} = Lemonldap::NG::Common::Crypto->new( $res->{key} ); };
eval {
$res->{cipher} = Lemonldap::NG::Common::Crypto->new( $res->{key} );
};
if ($@) {
$msg .= "Bad key: $@. \n";
}
......
......@@ -475,7 +475,7 @@ sub _casMetaDataNodes {
# Return all exported attributes if asked
if ( $query =~
/^(?:cas${type}MetaDataExportedVars|casSrvMetaDataOptionsProxiedServices)$/
/^(?:cas${type}MetaDataExportedVars|casSrvMetaDataOptionsProxiedServices)$/
)
{
my $pk = eval { $self->getConfKey( $req, $query )->{$partner} } // {};
......
......@@ -105,7 +105,8 @@ sub unset_header_in {
my $h = shift;
my $h2 = lc $h;
$h2 =~ s/-/_/g;
$request->env->{'psgi.r'}->headers_in->unset($h) if ( $h1 eq $h2 );
$request->env->{'psgi.r'}->headers_in->unset($h)
if ( $h1 eq $h2 );
return 1;
}
);
......
......@@ -104,10 +104,12 @@ sub init {
}
$self->menuLinks( [] );
if ( my $portal =
if (
my $portal =
$conf->{cfgNum}
? Lemonldap::NG::Handler::PSGI::Main->tsv->{portal}->()
: $conf->{portal} )
: $conf->{portal}
)
{
push @{ $self->menuLinks },
{
......
......@@ -370,9 +370,10 @@ sub attributes {
documentation => 'Show error if session is expired',
},
portalErrorOnMailNotFound => {
type => 'bool',
default => 0,
documentation => 'Show error if mail is not found in password reset process',
type => 'bool',
default => 0,
documentation =>
'Show error if mail is not found in password reset process',
},
portalOpenLinkInNewWindow => {
type => 'bool',
......@@ -2699,7 +2700,7 @@ m{^(?:ldapi://[^/]*/?|\w[\w\-\.]*(?::\d{1,5})?|ldap(?:s|\+tls)?://\w[\w\-\.]*(?:
oidcRPMetaDataOptionsBypassConsent =>
{ type => 'bool', help => 'openidconnectclaims.html', default => 0 },
oidcRPMetaDataOptionsPostLogoutRedirectUris => { type => 'text', },
oidcRPMetaDataOptionsLogoutUrl => {
oidcRPMetaDataOptionsLogoutUrl => {
type => 'url',
documentation => 'Logout URL',
},
......
......@@ -172,19 +172,20 @@ sub tree {
title => 'dbiPassword',
help => 'authdbi.html#password',
form => 'simpleInputContainer',
nodes => ['dbiAuthPasswordHash',
{
title => 'dbiDynamicHash',
help => 'authdbi.html#password',
form => 'simpleInputContainer',
nodes => [
'dbiDynamicHashEnabled',
'dbiDynamicHashValidSchemes',
'dbiDynamicHashValidSaltedSchemes',
'dbiDynamicHashNewPasswordScheme'
]
}
]
nodes => [
'dbiAuthPasswordHash',
{
title => 'dbiDynamicHash',
help => 'authdbi.html#password',
form => 'simpleInputContainer',
nodes => [
'dbiDynamicHashEnabled',
'dbiDynamicHashValidSchemes',
'dbiDynamicHashValidSaltedSchemes',
'dbiDynamicHashNewPasswordScheme'
]
}
]
}
]
},
......
......@@ -473,10 +473,13 @@ sub _scanNodes {
}
}
elsif ( $target =~
/^(?:$casSrvMetaDataNodeKeys|$casAppMetaDataNodeKeys)/o )
/^(?:$casSrvMetaDataNodeKeys|$casAppMetaDataNodeKeys)/o
)
{
$self->set( $optKey, [ $oldName, $key ],
$target, $leaf->{data} );
$self->set(
$optKey, [ $oldName, $key ],
$target, $leaf->{data}
);
}
else {
push @{ $self->errors },
......
......@@ -315,8 +315,8 @@ sub tests {
my %entityIds;
foreach my $spId ( keys %{ $conf->{samlSPMetaDataXML} } ) {
unless (
$conf->{samlSPMetaDataXML}->{$spId}->{samlSPMetaDataXML}
=~ /entityID=(['"])(.+?)\1/si )
$conf->{samlSPMetaDataXML}->{$spId}->{samlSPMetaDataXML} =~
/entityID=(['"])(.+?)\1/si )
{
push @msg, "$spId SAML metadata has no EntityID";
$res = 0;
......
......@@ -78,7 +78,8 @@ sub extractFormInfo {
# another backend (Combination)
# switch to another backend
elsif ( defined $req->param('kerberos') ) {
$self->userLogger->warn('Kerberos authentication has failed, back to portal');
$self->userLogger->warn(
'Kerberos authentication has failed, back to portal');
return PE_BADCREDENTIALS;
}
......@@ -110,16 +111,11 @@ sub extractFormInfo {
$ENV{KRB5_KTNAME} = $self->keytab;
my $gss_client_name;
my $status = GSSAPI::Context::accept(
my $server_context,
GSS_C_NO_CREDENTIAL,
$data,
GSS_C_NO_CHANNEL_BINDINGS,
$gss_client_name,
undef,
my $gss_output_token,
my $out_flags,
my $out_time,
my $gss_delegated_cred
my $server_context, GSS_C_NO_CREDENTIAL,
$data, GSS_C_NO_CHANNEL_BINDINGS,
$gss_client_name, undef,
my $gss_output_token, my $out_flags,
my $out_time, my $gss_delegated_cred
);
unless ($status) {
$self->logger->error('Unable to accept security context');
......
......@@ -331,7 +331,7 @@ sub validateST {
my $proxy_url;
if (%$proxied) {
$proxy_url = $self->p->fullUrl($req);
die if($proxy_url =~ /casProxy=1/);
die if ( $proxy_url =~ /casProxy=1/ );
$proxy_url .= ( $proxy_url =~ /\?/ ? '&' : '?' ) . 'casProxy=1';
if ( $self->conf->{authChoiceParam}
and my $tmp = $req->param( $self->conf->{authChoiceParam} ) )
......
......@@ -22,28 +22,30 @@ sub confirm {
sub modifyPassword {
my ( $self, $req, $pwd ) = @_;
my $userCol = $self->conf->{dbiAuthLoginCol};
my $userCol = $self->conf->{dbiAuthLoginCol};
my $passwordCol = $self->conf->{dbiAuthPasswordCol};
my $table = $self->conf->{dbiAuthTable};
my $table = $self->conf->{dbiAuthTable};
my $dynamicHash = $self->conf->{dbiDynamicHashEnabled} || 0;
my $passwordsql;
if ( $dynamicHash == 1 ) {
# Dynamic password hashes
$passwordsql =
$self->dynamic_hash_new_password( $self->dbh, $req->user, $pwd, $table, $userCol, $passwordCol );
$self->dynamic_hash_new_password( $self->dbh, $req->user, $pwd,
$table, $userCol, $passwordCol );
}
else
{
else {
# Static Password hash
$passwordsql = $self->hash_password( "?", $self->conf->{dbiAuthPasswordHash} );
$passwordsql =
$self->hash_password( "?", $self->conf->{dbiAuthPasswordHash} );
}
eval {
my $sth = $self->dbh->prepare(
"UPDATE $table SET $passwordCol=$passwordsql WHERE $userCol=?");
$sth->execute( $pwd, $req->user ) if $passwordsql =~ /.*\?.*/;
$sth->execute( $req->user ) unless $passwordsql =~ /.*\?.*/;
"UPDATE $table SET $passwordCol=$passwordsql WHERE $userCol=?");
$sth->execute( $pwd, $req->user ) if $passwordsql =~ /.*\?.*/;
$sth->execute( $req->user ) unless $passwordsql =~ /.*\?.*/;
};
if ($@) {
......
......@@ -10,12 +10,12 @@ extends 'Lemonldap::NG::Portal::Password::Base';
our $VERSION = '2.0.0';
sub init {1}
sub init { 1 }
sub confirm {1}
sub confirm { 1 }
sub modifyPassword {
PE_PASSWORD_OK
PE_PASSWORD_OK;
}
1;
......@@ -7,7 +7,7 @@ BEGIN {
}
my $maintests = 8;
my $debug = 'error';
my $debug = 'error';
SKIP: {
eval "require GSSAPI";
......
......@@ -86,9 +86,9 @@ expectAuthenticatedAs( $res, 'french' );
ok( $res = $sp->_get("/sessions/global/$spId"), 'Get UTF-8' );
expectOK($res);
ok( $res = eval { JSON::from_json( $res->[2]->[0] ) }, ' GET JSON' )
or print STDERR $@;
or print STDERR $@;
ok( $res->{cn} eq 'Frédéric Accents', 'UTF-8 values' )
or explain( $res, 'cn => Frédéric Accents' );
or explain( $res, 'cn => Frédéric Accents' );
count(3);
# Logout initiated by SP
......@@ -212,16 +212,16 @@ sub issuer {
return LLNG::Manager::Test->new(
{
ini => {
logLevel => $debug,
templatesDir => 'site/htdocs/static',
domain => 'idp.com',
portal => 'http://auth.idp.com',
authentication => 'Demo',
userDB => 'Same',
issuerDBCASActivation => 1,
casAttr => 'uid',
casAccessControlPolicy => 'error',
multiValuesSeparator => ';',
logLevel => $debug,
templatesDir => 'site/htdocs/static',
domain => 'idp.com',
portal => 'http://auth.idp.com',
authentication => 'Demo',
userDB => 'Same',
issuerDBCASActivation => 1,
casAttr => 'uid',
casAccessControlPolicy => 'error',
multiValuesSeparator => ';',
casAppMetaDataExportedVars => {
sp => {
cn => 'cn',
......
......@@ -245,14 +245,14 @@ sub sp {
return LLNG::Manager::Test->new(
{
ini => {
logLevel => $debug,
domain => 'sp.com',
portal => 'http://auth.sp.com',
authentication => 'CAS',
userDB => 'CAS',
restSessionServer => 1,
issuerDBCASActivation => 0,
multiValuesSeparator => ';',
logLevel => $debug,
domain => 'sp.com',
portal => 'http://auth.sp.com',
authentication => 'CAS',
userDB => 'CAS',
restSessionServer => 1,
issuerDBCASActivation => 0,
multiValuesSeparator => ';',
casSrvMetaDataExportedVars => {
idp => {
cn => 'cn',
......
......@@ -67,6 +67,7 @@ ok( $res->{_session_id} eq $spId, ' Good ID' )
or explain( $res, "_session_id => $spId" );
ok( $res->{uid} eq 'french', ' Uid is french' )
or explain( $res, 'uid => french' );
#ok( $res->{cn} eq 'Frédéric Accents', 'UTF-8 values' )
# or explain( $res->{cn}, 'Frédéric Accents' );
count(4);
......
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