Commit 0da228ff authored by Yadd's avatar Yadd
Browse files

make tidy

parent 585bf4a2
...@@ -6,7 +6,7 @@ use Mouse; ...@@ -6,7 +6,7 @@ use Mouse;
our $VERSION = '2.0.0'; our $VERSION = '2.0.0';
# Object that provides lmLog and error methods (typically PSGI object) # Object that provides lmLog and error methods (typically PSGI object)
has p => ( is => 'rw', weak_ref => 1 ); has p => ( is => 'rw', weak_ref => 1 );
# Lemonldap::NG configuration hash ref # Lemonldap::NG configuration hash ref
has conf => ( is => 'rw', weak_ref => 1 ); has conf => ( is => 'rw', weak_ref => 1 );
......
...@@ -31,7 +31,7 @@ has notifField => ( ...@@ -31,7 +31,7 @@ has notifField => (
sub getNotifications { sub getNotifications {
my ( $self, $uid ) = @_; my ( $self, $uid ) = @_;
my $forUser = $self->get($uid); my $forUser = $self->get($uid);
my $forAll = $self->get( $self->conf->{notificationWildcard} ); my $forAll = $self->get( $self->conf->{notificationWildcard} );
if ( $forUser and $forAll ) { if ( $forUser and $forAll ) {
return { %$forUser, %$forAll }; return { %$forUser, %$forAll };
} }
......
...@@ -140,7 +140,7 @@ sub purge { ...@@ -140,7 +140,7 @@ sub purge {
return 0; return 0;
} }
my $clause = ($force ? '' : '(description={done}*)'); my $clause = ( $force ? '' : '(description={done}*)' );
return $self->_delete( '(&(objectClass=applicationProcess)' return $self->_delete( '(&(objectClass=applicationProcess)'
. "(description={uid}$u)" . "(description={uid}$u)"
. "(description={ref}$r)" . "(description={ref}$r)"
......
...@@ -41,7 +41,8 @@ sub retrieveSession { ...@@ -41,7 +41,8 @@ sub retrieveSession {
my ( $class, $id ) = @_; my ( $class, $id ) = @_;
# First check if session already exists # First check if session already exists
return 1 if ( $class->Lemonldap::NG::Handler::Main::Run::retrieveSession($id) ); return 1
if ( $class->Lemonldap::NG::Handler::Main::Run::retrieveSession($id) );
# Then ask portal to create it # Then ask portal to create it
if ( $class->createSession($id) ) { if ( $class->createSession($id) ) {
...@@ -115,7 +116,8 @@ sub hideCookie { ...@@ -115,7 +116,8 @@ sub hideCookie {
sub goToPortal { sub goToPortal {
my ( $class, $url, $arg ) = @_; my ( $class, $url, $arg ) = @_;
if ($arg) { if ($arg) {
return $class->Lemonldap::NG::Handler::Main::Run::goToPortal( $url, $arg ); return $class->Lemonldap::NG::Handler::Main::Run::goToPortal( $url,
$arg );
} }
else { else {
$class->set_header_out( $class->set_header_out(
......
...@@ -687,7 +687,7 @@ sub metadatas { ...@@ -687,7 +687,7 @@ sub metadatas {
my @a = $self->confAcc->available; my @a = $self->confAcc->available;
my $id = -1; my $id = -1;
my ($ind) = map { $id++; $_ == $res->{cfgNum} ? ($id) : () } @a; my ($ind) = map { $id++; $_ == $res->{cfgNum} ? ($id) : () } @a;
if ($ind) { $res->{prev} = $a[ $ind - 1 ]; } if ($ind) { $res->{prev} = $a[ $ind - 1 ]; }
if ( $ind and $ind < $#a ) { $res->{next} = $a[ $ind + 1 ]; } if ( $ind and $ind < $#a ) { $res->{next} = $a[ $ind + 1 ]; }
$self->userNotice( 'User ' $self->userNotice( 'User '
. $self->userId($req) . $self->userId($req)
...@@ -1013,17 +1013,18 @@ sub applyConf { ...@@ -1013,17 +1013,18 @@ sub applyConf {
# Parse apply values # Parse apply values
while ( my ( $host, $request ) = each %reloadUrls ) { while ( my ( $host, $request ) = each %reloadUrls ) {
my $r = HTTP::Request->new( 'GET', "http://$host$request"); my $r = HTTP::Request->new( 'GET', "http://$host$request" );
if ($request =~ /^https?:\/\/[^\/]+.*$/) { if ( $request =~ /^https?:\/\/[^\/]+.*$/ ) {
my $url = URI::URL->new($request); my $url = URI::URL->new($request);
my $targetUrl = $url->scheme."://".$host; my $targetUrl = $url->scheme . "://" . $host;
$targetUrl .= ":".$url->port if defined ($url->port); $targetUrl .= ":" . $url->port if defined( $url->port );
$targetUrl .= $url->full_path; $targetUrl .= $url->full_path;
$r = $r =
HTTP::Request->new( 'GET', $targetUrl, HTTP::Request->new( 'GET', $targetUrl,
HTTP::Headers->new( Host => $url->host ) ); HTTP::Headers->new( Host => $url->host ) );
if (defined $url->userinfo && $url->userinfo =~/^([^:]+):(.*)$/) { if ( defined $url->userinfo && $url->userinfo =~ /^([^:]+):(.*)$/ )
$r->authorization_basic($1,$2); {
$r->authorization_basic( $1, $2 );
} }
} }
......
...@@ -280,8 +280,8 @@ sub newNotification { ...@@ -280,8 +280,8 @@ sub newNotification {
) . ">$json->{xml}</notification></root>"; ) . ">$json->{xml}</notification></root>";
unless ( eval { $self->notifAccess->newNotification($newNotif) } ) { unless ( eval { $self->notifAccess->newNotification($newNotif) } ) {
$self->lmLog( "Notification not created: $@", 'error'); $self->lmLog( "Notification not created: $@", 'error' );
return $self->sendError( $req, "Notification not created: $@", 200); return $self->sendError( $req, "Notification not created: $@", 200 );
} }
else { else {
return $self->sendJSONresponse( $req, { result => 1 } ); return $self->sendJSONresponse( $req, { result => 1 } );
...@@ -337,8 +337,9 @@ sub deleteDoneNotification { ...@@ -337,8 +337,9 @@ sub deleteDoneNotification {
my ( $uid, $ref, $date ) = ( $id =~ /([^_]+?)_([^_]+?)_(.+)/ ); my ( $uid, $ref, $date ) = ( $id =~ /([^_]+?)_([^_]+?)_(.+)/ );
my $identifier = $self->notifAccess->getIdentifier( $uid, $ref, $date ); my $identifier = $self->notifAccess->getIdentifier( $uid, $ref, $date );
unless ( eval { $self->notifAccess->purge($identifier) } ) { unless ( eval { $self->notifAccess->purge($identifier) } ) {
$self->lmLog( "Notification $identifier not purged ($@)", 'warn'); $self->lmLog( "Notification $identifier not purged ($@)", 'warn' );
return $self->sendError( $req, "Notification $identifier not purged ($@)", 400); return $self->sendError( $req,
"Notification $identifier not purged ($@)", 400 );
} }
$self->lmLog( "Notification $identifier purged", 'info' ); $self->lmLog( "Notification $identifier purged", 'info' );
......
...@@ -29,7 +29,14 @@ sub newSession { ...@@ -29,7 +29,14 @@ sub newSession {
); );
count(1); count(1);
$tmp->update( $tmp->update(
{ ipAddr => $ip, _whatToTrace => $uid, uid => $uid, _utime => time, _session_kind => 'SSO' } ); {
ipAddr => $ip,
_whatToTrace => $uid,
uid => $uid,
_utime => time,
_session_kind => 'SSO'
}
);
return $tmp->{id}; return $tmp->{id};
} }
......
...@@ -35,7 +35,8 @@ sub authenticate { ...@@ -35,7 +35,8 @@ sub authenticate {
sub setAuthSessionInfo { sub setAuthSessionInfo {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;
$req->{sessionInfo}->{authenticationLevel} = $self->conf->{apacheAuthnLevel}; $req->{sessionInfo}->{authenticationLevel} =
$self->conf->{apacheAuthnLevel};
PE_OK; PE_OK;
} }
......
...@@ -135,9 +135,11 @@ sub authenticate { ...@@ -135,9 +135,11 @@ sub authenticate {
sub setAuthSessionInfo { sub setAuthSessionInfo {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;
$req->{sessionInfo}->{authenticationLevel} = $self->conf->{browserIdAuthnLevel}; $req->{sessionInfo}->{authenticationLevel} =
$req->{sessionInfo}->{_browserIdAnswer} = $self->conf->{browserIdAnswer}; $self->conf->{browserIdAuthnLevel};
$req->{sessionInfo}->{_browserIdAnswerRaw} = $self->conf->{browserIdAnswerRaw}; $req->{sessionInfo}->{_browserIdAnswer} = $self->conf->{browserIdAnswer};
$req->{sessionInfo}->{_browserIdAnswerRaw} =
$self->conf->{browserIdAnswerRaw};
PE_OK; PE_OK;
} }
......
...@@ -121,7 +121,8 @@ sub authenticate { ...@@ -121,7 +121,8 @@ sub authenticate {
sub setAuthSessionInfo { sub setAuthSessionInfo {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;
$req->{sessionInfo}->{authenticationLevel} = $self->conf->{facebookAuthnLevel}; $req->{sessionInfo}->{authenticationLevel} =
$self->conf->{facebookAuthnLevel};
PE_OK; PE_OK;
} }
......
...@@ -44,14 +44,14 @@ sub authLogout { ...@@ -44,14 +44,14 @@ sub authLogout {
sub authForce { sub authForce {
my $self = shift; my $self = shift;
$self->_sub('authInit'); $self->_sub('authInit');
my $s = $self->{_multi}->{last}->[0] . "::authForce"; my $s = $self->{_multi}->{last}->[0] . "::authForce";
return &{$s}($self); return &{$s}($self);
} }
sub getDisplayType { sub getDisplayType {
my $self = shift; my $self = shift;
return unless defined $self->{_multi}->{last}; return unless defined $self->{_multi}->{last};
my $s = $self->{_multi}->{last}->[0] . "::getDisplayType"; my $s = $self->{_multi}->{last}->[0] . "::getDisplayType";
return &{$s}; return &{$s};
} }
......
...@@ -81,7 +81,8 @@ sub extractFormInfo { ...@@ -81,7 +81,8 @@ sub extractFormInfo {
# Forward hidden fields # Forward hidden fields
if ( exists $self->{portalHiddenFormValues} ) { if ( exists $self->{portalHiddenFormValues} ) {
$self->lmLog( "Add hidden values to Twitter redirect URL", 'debug' ); $self->lmLog( "Add hidden values to Twitter redirect URL",
'debug' );
foreach ( keys %{ $self->{portalHiddenFormValues} } ) { foreach ( keys %{ $self->{portalHiddenFormValues} } ) {
$callback_url .= $callback_url .=
......
...@@ -66,7 +66,8 @@ sub computeGetParams { ...@@ -66,7 +66,8 @@ sub computeGetParams {
my $value = my $value =
eval { uri_escape( $req->{sessionInfo}->{ $prms->{$param} } ) }; eval { uri_escape( $req->{sessionInfo}->{ $prms->{$param} } ) };
if ($@) { if ($@) {
$self->lmLog( "IssuerGet: unable to compute $param ($@)", 'error' ); $self->lmLog( "IssuerGet: unable to compute $param ($@)",
'error' );
return; return;
} }
$value =~ s/[\r\n\t]//; $value =~ s/[\r\n\t]//;
......
...@@ -21,7 +21,9 @@ sub init { ...@@ -21,7 +21,9 @@ sub init {
my ( $self, $type ) = @_; my ( $self, $type ) = @_;
$self->type($type); $self->type($type);
unless( $self->conf->{authChoiceModules} and %{ $self->conf->{authChoiceModules} } ) { unless ( $self->conf->{authChoiceModules}
and %{ $self->conf->{authChoiceModules} } )
{
$self->error("'authChoiceModules' is empty"); $self->error("'authChoiceModules' is empty");
return 0; return 0;
} }
......
...@@ -53,7 +53,7 @@ sub init { ...@@ -53,7 +53,7 @@ sub init {
sub _redirect { sub _redirect {
my ( $self, $req, @path ) = @_; my ( $self, $req, @path ) = @_;
$self->lmLog('Processing _redirect','debug'); $self->lmLog( 'Processing _redirect', 'debug' );
my $prms = $req->params; my $prms = $req->params;
foreach my $k ( keys %$prms ) { foreach my $k ( keys %$prms ) {
$self->p->setHiddenFormValue( $req, $k, $prms->{$k}, '', 0 ); $self->p->setHiddenFormValue( $req, $k, $prms->{$k}, '', 0 );
...@@ -92,7 +92,7 @@ sub _pRedirect { ...@@ -92,7 +92,7 @@ sub _pRedirect {
# Case 3: authentified user, launch # Case 3: authentified user, launch
sub _forAuthUser { sub _forAuthUser {
my ( $self, $req, @path ) = @_; my ( $self, $req, @path ) = @_;
$self->lmLog('Processing _forAuthUser','debug'); $self->lmLog( 'Processing _forAuthUser', 'debug' );
return $self->p->do( return $self->p->do(
$req, $req,
[ [
......
...@@ -127,19 +127,18 @@ sub authLogout { ...@@ -127,19 +127,18 @@ sub authLogout {
sub deleteSession { sub deleteSession {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;
my $apacheSession = $self->getApacheSession( $req->id ); my $apacheSession = $self->getApacheSession( $req->id );
my $id = $req->id; my $id = $req->id;
unless ($apacheSession) { unless ($apacheSession) {
$self->lmLog( "Session $id already deleted", 'debug' ); $self->lmLog( "Session $id already deleted", 'debug' );
return PE_OK; return PE_OK;
} }
unless ( $self->_deleteSession( $req, $apacheSession ) ) { unless ( $self->_deleteSession( $req, $apacheSession ) ) {
$self->lmLog( "Unable to delete session $id", 'error' ); $self->lmLog( "Unable to delete session $id", 'error' );
$self->lmLog( $apacheSession->error, 'error' ); $self->lmLog( $apacheSession->error, 'error' );
return PE_ERROR; return PE_ERROR;
} }
else { else {
$self->lmLog( "Session $id deleted from global storage", $self->lmLog( "Session $id deleted from global storage", 'debug' );
'debug' );
} }
# TODO # TODO
......
...@@ -22,7 +22,7 @@ has vars => ( ...@@ -22,7 +22,7 @@ has vars => (
sub init { sub init {
my ($self) = @_; my ($self) = @_;
unless ( $self->p->getModule(undef,'auth') =~ /^Facebook/ ) { unless ( $self->p->getModule( undef, 'auth' ) =~ /^Facebook/ ) {
$self->error( $self->error(
"UserDBFacebook isn't useable unless authentication module is set to Facebook" "UserDBFacebook isn't useable unless authentication module is set to Facebook"
); );
......
...@@ -4,7 +4,7 @@ use strict; ...@@ -4,7 +4,7 @@ use strict;
use Mouse; use Mouse;
use Lemonldap::NG::Portal::Main::Constants 'PE_OK'; use Lemonldap::NG::Portal::Main::Constants 'PE_OK';
extends 'Lemonldap::NG::Common::Module','Lemonldap::NG::Portal::Lib::Proxy'; extends 'Lemonldap::NG::Common::Module', 'Lemonldap::NG::Portal::Lib::Proxy';
our $VERSION = '2.0.0'; our $VERSION = '2.0.0';
......
...@@ -6,8 +6,7 @@ use Lemonldap::NG::Portal::Main::Constants qw(PE_OK); ...@@ -6,8 +6,7 @@ use Lemonldap::NG::Portal::Main::Constants qw(PE_OK);
our $VERSION = '2.0.0'; our $VERSION = '2.0.0';
extends 'Lemonldap::NG::Common::Module', extends 'Lemonldap::NG::Common::Module', 'Lemonldap::NG::Portal::Lib::Remote';
'Lemonldap::NG::Portal::Lib::Remote';
# RUNNING METHODS # RUNNING METHODS
......
...@@ -22,14 +22,14 @@ sub init { ...@@ -22,14 +22,14 @@ sub init {
my ($self) = @_; my ($self) = @_;
unless ( $self->p->getModule( undef, 'auth' ) =~ /^SAML/ ) { unless ( $self->p->getModule( undef, 'auth' ) =~ /^SAML/ ) {
$self->error( $self->error( "SAML user module requires SAML authentication" );
"SAML user module requires SAML authentication"
);
return 0; return 0;
} }
# SAML service has been already loaded # SAML service has been already loaded
$self->lassoServer($self->p->loadedModules->{'Lemonldap::NG::Portal::Auth::SAML'}->lassoServer); $self->lassoServer(
$self->p->loadedModules->{'Lemonldap::NG::Portal::Auth::SAML'}
->lassoServer );
return 1; return 1;
} }
...@@ -57,18 +57,21 @@ sub setSessionInfo { ...@@ -57,18 +57,21 @@ sub setSessionInfo {
# Get all required attributes, not already set # Get all required attributes, not already set
# in setAuthSessionInfo() # in setAuthSessionInfo()
foreach ( foreach (
keys %{ $self->conf->{samlIDPMetaDataExportedAttributes}->{$idpConfKey} } ) keys %{ $self->conf->{samlIDPMetaDataExportedAttributes}->{$idpConfKey}
} )
{ {
# Extract fields from exportedAttr value # Extract fields from exportedAttr value
my ( $mandatory, $name, $format, $friendly_name ) = my ( $mandatory, $name, $format, $friendly_name ) =
split( /;/, split( /;/,
$self->conf->{samlIDPMetaDataExportedAttributes}->{$idpConfKey}->{$_} ); $self->conf->{samlIDPMetaDataExportedAttributes}->{$idpConfKey}
->{$_} );
# Keep mandatory attributes not sent in authentication response # Keep mandatory attributes not sent in authentication response
if ( $mandatory and not defined $req->{sessionInfo}->{$_} ) { if ( $mandatory and not defined $req->{sessionInfo}->{$_} ) {
$exportedAttr->{$_} = $exportedAttr->{$_} =
$self->conf->{samlIDPMetaDataExportedAttributes}->{$idpConfKey}->{$_}; $self->conf->{samlIDPMetaDataExportedAttributes}->{$idpConfKey}
->{$_};
$self->lmLog( "Attribute $_ will be requested to $idpConfKey", $self->lmLog( "Attribute $_ will be requested to $idpConfKey",
'debug' ); 'debug' );
} }
......
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