environments/ppa-mbqj77/deployments/1
Xavier Guimard 9 years ago
parent 585bf4a235
commit 0da228ff35
  1. 2
      lemonldap-ng-common/lib/Lemonldap/NG/Common/Module.pm
  2. 2
      lemonldap-ng-common/lib/Lemonldap/NG/Common/Notifications.pm
  3. 2
      lemonldap-ng-common/lib/Lemonldap/NG/Common/Notifications/LDAP.pm
  4. 6
      lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Lib/AuthBasic.pm
  5. 17
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Conf.pm
  6. 9
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Notifications.pm
  7. 9
      lemonldap-ng-manager/t/40-sessions.t
  8. 3
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/Apache.pm
  9. 8
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/BrowserID.pm
  10. 3
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Auth/Facebook.pm
  11. 4
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthMulti.pm
  12. 3
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthTwitter.pm
  13. 3
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Issuer/Get.pm
  14. 4
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/Choice.pm
  15. 4
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Issuer.pm
  16. 7
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Process.pm
  17. 2
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDB/Facebook.pm
  18. 2
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDB/Proxy.pm
  19. 3
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDB/Remote.pm
  20. 17
      lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDB/SAML.pm
  21. 3
      lemonldap-ng-portal/t/26-AuthRemote.t
  22. 11
      lemonldap-ng-portal/t/30-Auth-and-issuer-SAML-Artifact-IdP-initiated.t
  23. 11
      lemonldap-ng-portal/t/30-Auth-and-issuer-SAML-POST-IdP-initiated.t
  24. 10
      lemonldap-ng-portal/t/31-Auth-and-issuer-CAS.t
  25. 2
      lemonldap-ng-portal/t/50-IssuerGet.t
  26. 2
      lemonldap-ng-portal/t/test-lib.pm

@ -6,7 +6,7 @@ use Mouse;
our $VERSION = '2.0.0';
# 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
has conf => ( is => 'rw', weak_ref => 1 );

@ -31,7 +31,7 @@ has notifField => (
sub getNotifications {
my ( $self, $uid ) = @_;
my $forUser = $self->get($uid);
my $forAll = $self->get( $self->conf->{notificationWildcard} );
my $forAll = $self->get( $self->conf->{notificationWildcard} );
if ( $forUser and $forAll ) {
return { %$forUser, %$forAll };
}

@ -140,7 +140,7 @@ sub purge {
return 0;
}
my $clause = ($force ? '' : '(description={done}*)');
my $clause = ( $force ? '' : '(description={done}*)' );
return $self->_delete( '(&(objectClass=applicationProcess)'
. "(description={uid}$u)"
. "(description={ref}$r)"

@ -41,7 +41,8 @@ sub retrieveSession {
my ( $class, $id ) = @_;
# 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
if ( $class->createSession($id) ) {
@ -115,7 +116,8 @@ sub hideCookie {
sub goToPortal {
my ( $class, $url, $arg ) = @_;
if ($arg) {
return $class->Lemonldap::NG::Handler::Main::Run::goToPortal( $url, $arg );
return $class->Lemonldap::NG::Handler::Main::Run::goToPortal( $url,
$arg );
}
else {
$class->set_header_out(

@ -687,7 +687,7 @@ sub metadatas {
my @a = $self->confAcc->available;
my $id = -1;
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 ]; }
$self->userNotice( 'User '
. $self->userId($req)
@ -1013,17 +1013,18 @@ sub applyConf {
# Parse apply values
while ( my ( $host, $request ) = each %reloadUrls ) {
my $r = HTTP::Request->new( 'GET', "http://$host$request");
if ($request =~ /^https?:\/\/[^\/]+.*$/) {
my $url = URI::URL->new($request);
my $targetUrl = $url->scheme."://".$host;
$targetUrl .= ":".$url->port if defined ($url->port);
my $r = HTTP::Request->new( 'GET', "http://$host$request" );
if ( $request =~ /^https?:\/\/[^\/]+.*$/ ) {
my $url = URI::URL->new($request);
my $targetUrl = $url->scheme . "://" . $host;
$targetUrl .= ":" . $url->port if defined( $url->port );
$targetUrl .= $url->full_path;
$r =
HTTP::Request->new( 'GET', $targetUrl,
HTTP::Headers->new( Host => $url->host ) );
if (defined $url->userinfo && $url->userinfo =~/^([^:]+):(.*)$/) {
$r->authorization_basic($1,$2);
if ( defined $url->userinfo && $url->userinfo =~ /^([^:]+):(.*)$/ )
{
$r->authorization_basic( $1, $2 );
}
}

@ -280,8 +280,8 @@ sub newNotification {
) . ">$json->{xml}</notification></root>";
unless ( eval { $self->notifAccess->newNotification($newNotif) } ) {
$self->lmLog( "Notification not created: $@", 'error');
return $self->sendError( $req, "Notification not created: $@", 200);
$self->lmLog( "Notification not created: $@", 'error' );
return $self->sendError( $req, "Notification not created: $@", 200 );
}
else {
return $self->sendJSONresponse( $req, { result => 1 } );
@ -337,8 +337,9 @@ sub deleteDoneNotification {
my ( $uid, $ref, $date ) = ( $id =~ /([^_]+?)_([^_]+?)_(.+)/ );
my $identifier = $self->notifAccess->getIdentifier( $uid, $ref, $date );
unless ( eval { $self->notifAccess->purge($identifier) } ) {
$self->lmLog( "Notification $identifier not purged ($@)", 'warn');
return $self->sendError( $req, "Notification $identifier not purged ($@)", 400);
$self->lmLog( "Notification $identifier not purged ($@)", 'warn' );
return $self->sendError( $req,
"Notification $identifier not purged ($@)", 400 );
}
$self->lmLog( "Notification $identifier purged", 'info' );

@ -29,7 +29,14 @@ sub newSession {
);
count(1);
$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};
}

@ -35,7 +35,8 @@ sub authenticate {
sub setAuthSessionInfo {
my ( $self, $req ) = @_;
$req->{sessionInfo}->{authenticationLevel} = $self->conf->{apacheAuthnLevel};
$req->{sessionInfo}->{authenticationLevel} =
$self->conf->{apacheAuthnLevel};
PE_OK;
}

@ -135,9 +135,11 @@ sub authenticate {
sub setAuthSessionInfo {
my ( $self, $req ) = @_;
$req->{sessionInfo}->{authenticationLevel} = $self->conf->{browserIdAuthnLevel};
$req->{sessionInfo}->{_browserIdAnswer} = $self->conf->{browserIdAnswer};
$req->{sessionInfo}->{_browserIdAnswerRaw} = $self->conf->{browserIdAnswerRaw};
$req->{sessionInfo}->{authenticationLevel} =
$self->conf->{browserIdAuthnLevel};
$req->{sessionInfo}->{_browserIdAnswer} = $self->conf->{browserIdAnswer};
$req->{sessionInfo}->{_browserIdAnswerRaw} =
$self->conf->{browserIdAnswerRaw};
PE_OK;
}

@ -121,7 +121,8 @@ sub authenticate {
sub setAuthSessionInfo {
my ( $self, $req ) = @_;
$req->{sessionInfo}->{authenticationLevel} = $self->conf->{facebookAuthnLevel};
$req->{sessionInfo}->{authenticationLevel} =
$self->conf->{facebookAuthnLevel};
PE_OK;
}

@ -44,14 +44,14 @@ sub authLogout {
sub authForce {
my $self = shift;
$self->_sub('authInit');
my $s = $self->{_multi}->{last}->[0] . "::authForce";
my $s = $self->{_multi}->{last}->[0] . "::authForce";
return &{$s}($self);
}
sub getDisplayType {
my $self = shift;
return unless defined $self->{_multi}->{last};
my $s = $self->{_multi}->{last}->[0] . "::getDisplayType";
my $s = $self->{_multi}->{last}->[0] . "::getDisplayType";
return &{$s};
}

@ -81,7 +81,8 @@ sub extractFormInfo {
# Forward hidden fields
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} } ) {
$callback_url .=

@ -66,7 +66,8 @@ sub computeGetParams {
my $value =
eval { uri_escape( $req->{sessionInfo}->{ $prms->{$param} } ) };
if ($@) {
$self->lmLog( "IssuerGet: unable to compute $param ($@)", 'error' );
$self->lmLog( "IssuerGet: unable to compute $param ($@)",
'error' );
return;
}
$value =~ s/[\r\n\t]//;

@ -21,7 +21,9 @@ sub init {
my ( $self, $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");
return 0;
}

@ -53,7 +53,7 @@ sub init {
sub _redirect {
my ( $self, $req, @path ) = @_;
$self->lmLog('Processing _redirect','debug');
$self->lmLog( 'Processing _redirect', 'debug' );
my $prms = $req->params;
foreach my $k ( keys %$prms ) {
$self->p->setHiddenFormValue( $req, $k, $prms->{$k}, '', 0 );
@ -92,7 +92,7 @@ sub _pRedirect {
# Case 3: authentified user, launch
sub _forAuthUser {
my ( $self, $req, @path ) = @_;
$self->lmLog('Processing _forAuthUser','debug');
$self->lmLog( 'Processing _forAuthUser', 'debug' );
return $self->p->do(
$req,
[

@ -127,19 +127,18 @@ sub authLogout {
sub deleteSession {
my ( $self, $req ) = @_;
my $apacheSession = $self->getApacheSession( $req->id );
my $id = $req->id;
my $id = $req->id;
unless ($apacheSession) {
$self->lmLog( "Session $id already deleted", 'debug' );
return PE_OK;
}
unless ( $self->_deleteSession( $req, $apacheSession ) ) {
$self->lmLog( "Unable to delete session $id", 'error' );
$self->lmLog( $apacheSession->error, 'error' );
$self->lmLog( $apacheSession->error, 'error' );
return PE_ERROR;
}
else {
$self->lmLog( "Session $id deleted from global storage",
'debug' );
$self->lmLog( "Session $id deleted from global storage", 'debug' );
}
# TODO

@ -22,7 +22,7 @@ has vars => (
sub init {
my ($self) = @_;
unless ( $self->p->getModule(undef,'auth') =~ /^Facebook/ ) {
unless ( $self->p->getModule( undef, 'auth' ) =~ /^Facebook/ ) {
$self->error(
"UserDBFacebook isn't useable unless authentication module is set to Facebook"
);

@ -4,7 +4,7 @@ use strict;
use Mouse;
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';

@ -6,8 +6,7 @@ use Lemonldap::NG::Portal::Main::Constants qw(PE_OK);
our $VERSION = '2.0.0';
extends 'Lemonldap::NG::Common::Module',
'Lemonldap::NG::Portal::Lib::Remote';
extends 'Lemonldap::NG::Common::Module', 'Lemonldap::NG::Portal::Lib::Remote';
# RUNNING METHODS

@ -22,14 +22,14 @@ sub init {
my ($self) = @_;
unless ( $self->p->getModule( undef, 'auth' ) =~ /^SAML/ ) {
$self->error(
"SAML user module requires SAML authentication"
);
$self->error( "SAML user module requires SAML authentication" );
return 0;
}
# 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;
}
@ -57,18 +57,21 @@ sub setSessionInfo {
# Get all required attributes, not already set
# in setAuthSessionInfo()
foreach (
keys %{ $self->conf->{samlIDPMetaDataExportedAttributes}->{$idpConfKey} } )
keys %{ $self->conf->{samlIDPMetaDataExportedAttributes}->{$idpConfKey}
} )
{
# Extract fields from exportedAttr value
my ( $mandatory, $name, $format, $friendly_name ) =
split( /;/,
$self->conf->{samlIDPMetaDataExportedAttributes}->{$idpConfKey}->{$_} );
$self->conf->{samlIDPMetaDataExportedAttributes}->{$idpConfKey}
->{$_} );
# Keep mandatory attributes not sent in authentication response
if ( $mandatory and not defined $req->{sessionInfo}->{$_} ) {
$exportedAttr->{$_} =
$self->conf->{samlIDPMetaDataExportedAttributes}->{$idpConfKey}->{$_};
$self->conf->{samlIDPMetaDataExportedAttributes}->{$idpConfKey}
->{$_};
$self->lmLog( "Attribute $_ will be requested to $idpConfKey",
'debug' );
}

@ -26,7 +26,8 @@ my $client = LLNG::Manager::Test->new(
# Test redirection to remote portal
ok( $res = $client->_get( '/', accept => 'text/html' ), 'First request' );
count(1);
expectRedirection($res, 'http://auth2.example.com?url=aHR0cDovL2F1dGguZXhhbXBsZS5jb20v');
expectRedirection( $res,
'http://auth2.example.com?url=aHR0cDovL2F1dGguZXhhbXBsZS5jb20v' );
ok(
$res = $client->_get(

@ -49,10 +49,13 @@ SKIP: {
),
'Query IdP to access to SP'
);
my($url,$query) = expectRedirection($res,qr#http://auth.sp.com(/saml/proxySingleSignOnArtifact)\?(SAMLart=[^&]+)#);
switch('sp');
ok($res=$sp->_get($url,query=>$query,accept=>'test/html'),'Give artifact to SP');
expectRedirection($res,'http://auth.sp.com');
my ( $url, $query ) = expectRedirection( $res,
qr#http://auth.sp.com(/saml/proxySingleSignOnArtifact)\?(SAMLart=[^&]+)#
);
switch ('sp');
ok( $res = $sp->_get( $url, query => $query, accept => 'test/html' ),
'Give artifact to SP' );
expectRedirection( $res, 'http://auth.sp.com' );
my $spId = expectCookie($res);
# Verify authentication on SP

@ -98,9 +98,9 @@ SKIP: {
ok(
$res->[2]->[0] =~
m#iframe src="http://auth.idp.com(/saml/relaySingleLogoutPOST)\?(relay=.*?)"#s,
m#iframe src="http://auth.idp.com(/saml/relaySingleLogoutPOST)\?(relay=.*?)"#s,
'Get iframe request'
) or explain($res,'');
) or explain( $res, '' );
ok(
$res = $issuer->_get(
@ -114,7 +114,7 @@ SKIP: {
expectOK($res);
ok(
$res->[2]->[0] =~
m#<form.+?action="http://auth.sp.com(/saml/proxySingleLogout)".+?method="post"#,
m#<form.+?action="http://auth.sp.com(/saml/proxySingleLogout)".+?method="post"#,
'Form method is POST'
);
$url = $1;
@ -139,7 +139,7 @@ SKIP: {
expectOK($res);
ok(
$res->[2]->[0] =~
m#<form.+?action="http://auth.idp.com(/saml/singleLogoutReturn)".+?method="post"#,
m#<form.+?action="http://auth.idp.com(/saml/singleLogoutReturn)".+?method="post"#,
'Form method is POST'
);
$url = $1;
@ -151,7 +151,7 @@ SKIP: {
$s = "SAMLResponse=$1";
# Post SAML logout response to IdP
switch('issuer');
switch ('issuer');
ok(
$res = $sp->_post(
$url, IO::String->new($s),
@ -192,6 +192,7 @@ SKIP: {
$res->[2],
' <input type="hidden" name="SAMLRequest" id="SAMLRequest" value="...'
);
#print STDERR Dumper($res);
}

@ -38,7 +38,8 @@ SKIP: {
),
'Unauth SP request'
);
expectRedirection($res, 'http://auth.idp.com/cas/login?service=http://auth.sp.com/');
expectRedirection( $res,
'http://auth.idp.com/cas/login?service=http://auth.sp.com/' );
# Query IdP
switch ('issuer');
@ -70,7 +71,8 @@ SKIP: {
),
'Post authentication'
);
my ($query) = expectRedirection($res,qr#^http://auth.sp.com/\?(ticket=[^&]+)$#);
my ($query) =
expectRedirection( $res, qr#^http://auth.sp.com/\?(ticket=[^&]+)$# );
my $idpId = expectCookie($res);
# Back to SP
@ -82,7 +84,7 @@ SKIP: {
# Test authentication
ok( $res = $sp->_get( '/', cookie => "lemonldap=$spId" ), 'Get / on SP' );
expectOK($res);
expectAuthenticatedAs($res,'dwho');
expectAuthenticatedAs( $res, 'dwho' );
# Logout initiated by SP
ok(
@ -102,7 +104,7 @@ SKIP: {
);
# Query IdP with iframe src
my $url = $1;
my $url = $1;
$query = $2;
switch ('issuer');
ok(

@ -44,7 +44,7 @@ ok(
'GET request with good url'
);
count(1);
expectRedirection($res,"http://test1.example.com/?ID=$id");
expectRedirection( $res, "http://test1.example.com/?ID=$id" );
# Test not logged access
ok(

@ -91,7 +91,7 @@ sub expectCookie {
$cookieName ||= 'lemonldap';
my $cookies = getCookies($res);
my $id;
ok( defined($id = $cookies->{$cookieName}), "Get cookie $cookieName" )
ok( defined( $id = $cookies->{$cookieName} ), "Get cookie $cookieName" )
or explain( $res->[1], "Set-Cookie: $cookieName=something" );
count(1);
return $id;

Loading…
Cancel
Save