From 2d7c4fd864bb65e61207e7c4da16bd60335dc95d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Oudot?= Date: Sat, 8 Sep 2012 17:20:08 +0000 Subject: [PATCH] Allow getCookies webservice to be used with Multi backend (#519) --- .../lib/Lemonldap/NG/Portal/AuthSSL.pm | 4 +++- .../lib/Lemonldap/NG/Portal/Simple.pm | 1 + .../lib/Lemonldap/NG/Portal/_Multi.pm | 10 +++++++--- .../lib/Lemonldap/NG/Portal/_SOAP.pm | 17 ++++++++++++++--- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthSSL.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthSSL.pm index 1657399dd..744625f3e 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthSSL.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/AuthSSL.pm @@ -9,9 +9,11 @@ use strict; use Lemonldap::NG::Portal::Simple; use Lemonldap::NG::Portal::AuthNull; -our $VERSION = '1.2.0'; +our $VERSION = '1.2.2'; our @ISA = qw(Lemonldap::NG::Portal::AuthNull); +*authenticate = *extractFormInfo; + ## @apmethod int authInit() # Check if SSL environment variables are set. # @return Lemonldap::NG::Portal constant diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm index 766acf240..db38c085b 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm @@ -1931,6 +1931,7 @@ sub existingSession { #@return Lemonldap::NG::Portal constant sub extractFormInfo { my $self = shift; + return PE_OK if $self->{skipExtractFormInfo}; $self->{checkLogins} = $self->param('checkLogins'); return $self->SUPER::extractFormInfo; } diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_Multi.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_Multi.pm index 948d3687d..454d94716 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_Multi.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_Multi.pm @@ -12,7 +12,7 @@ package Lemonldap::NG::Portal::_Multi; use Lemonldap::NG::Portal::Simple; -our $VERSION = '1.0.6'; +our $VERSION = '1.2.2'; ## @cmethod Lemonldap::NG::Portal::_Multi new(Lemonldap::NG::Portal::Simple portal) # Constructor @@ -71,7 +71,8 @@ sub try { if ( $ci = $self->{p}->safe->reval( $self->{stack}->[$type]->[0]->{c} ) ) { # Log used module - $self->{p}->lmLog( "Multi (type $type): trying module $old", 'debug' ); + $self->{p} + ->lmLog( "Multi (type $type): trying $sub for module $old", 'debug' ); # Run subroutine $res = $self->{p}->$s(); @@ -104,6 +105,7 @@ sub try { # return true if an other module is available sub next { my ( $self, $type ) = splice @_; + if ( $self->{stack}->[$type]->[0]->{n} eq $self->{stack}->[ 1 - $type ]->[0]->{n} and $self->{stack}->[ 1 - $type ]->[1] ) @@ -126,9 +128,11 @@ sub next { sub replay { my ( $self, $sub ) = splice @_; my @subs = (); + $self->{p}->lmLog( "Replay all methods until sub $sub", 'debug' ); + foreach ( qw(authInit extractFormInfo userDBInit getUser setAuthSessionInfo - setSessionInfo setGroups authFinish) + setSessionInfo setGroups authenticate authFinish) ) { push @subs, $_; diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_SOAP.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_SOAP.pm index 8bbe4456c..6376c945b 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_SOAP.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/_SOAP.pm @@ -11,7 +11,7 @@ use Lemonldap::NG::Portal::_LibAccess; require SOAP::Lite; use base qw(Lemonldap::NG::Portal::_LibAccess); -our $VERSION = '1.2.0'; +our $VERSION = '1.2.2'; ## @method void startSoapServices() # Check the URI requested (PATH_INFO environment variable) and launch the @@ -76,21 +76,32 @@ _RETURN $getCookiesResponse Response #@return session => { error => code , cookies => { cookieName1 => value ,... } } sub getCookies { my ( $self, $user, $password, $sessionid ) = splice @_; + $self->{user} = $user; $self->{password} = $password; $self->{id} = $sessionid if ( defined($sessionid) && $sessionid ); $self->{error} = PE_OK; - $self->lmLog( "SOAP authentication request for $self->{user}", 'debug' ); + $self->lmLog( "SOAP authentication request for $user", 'debug' ); + + # Skip extractFormInfo step, as we already get input data + $self->{skipExtractFormInfo} = 1; + + # User and password are required unless ( $self->{user} && $self->{password} ) { $self->{error} = PE_FORMEMPTY; } + + # Launch process else { $self->{error} = $self->_subProcess( - qw(authInit userDBInit getUser setAuthSessionInfo + qw(authInit userDBInit extractFormInfo getUser setAuthSessionInfo setSessionInfo setMacros setGroups setPersistentSessionInfo setLocalGroups authenticate grantSession removeOther store authFinish buildCookie) ); + $self->lmLog( + "SOAP authentication result for $user: code $self->{error}", + 'debug' ); $self->updateSession(); } my @tmp = ();