Commit 898b52ab authored by Clément OUDOT's avatar Clément OUDOT

Show error from Common::Session module in logs (#LEMONLDAP-741)

git-svn-id: svn://svn.forge.objectweb.org/svnroot/lemonldap/branches/lemonldap-ng_version_1_4-bugfixes@3515 1dbb9719-a921-0410-b57f-c3a383c2c641
parent 881a62af
......@@ -58,6 +58,11 @@ has 'cacheModuleOptions' => (
isa => 'HashRef|Undef',
);
has 'error' => (
is => 'rw',
isa => 'Str|Undef',
);
sub BUILD {
my $self = shift;
......@@ -128,7 +133,12 @@ sub _tie_session {
}
};
return undef if ( $@ or not tied(%h) );
if ( $@ or not tied(%h) ) {
my $msg = "Session cannot be tied";
$msg .= ": $@" if $@;
$self->error($msg);
return undef;
}
return \%h;
}
......@@ -144,7 +154,10 @@ sub update {
my $self = shift;
my $infos = shift;
return 0 unless ( ref $infos eq "HASH" );
unless ( ref $infos eq "HASH" ) {
$self->error("You need to provide a HASHREF");
return 0;
}
my $data = $self->_tie_session;
......@@ -164,6 +177,7 @@ sub update {
return 1;
}
$self->error("No data found in session");
return 0;
}
......@@ -174,7 +188,11 @@ sub remove {
eval { tied(%$data)->delete(); };
return 0 if $@;
if ($@) {
$self->error("Unable to delete session: $@");
return 0;
}
return 1;
}
......
......@@ -18,7 +18,7 @@ use Lemonldap::NG::Handler::SharedConf qw(:all);
#link Lemonldap::NG::Handler::_CGI protected _handler
our $VERSION = '1.2.3';
our $VERSION = '1.4.1';
## @cmethod Lemonldap::NG::Handler::CGI new(hashRef args)
# Constructor.
......@@ -116,9 +116,11 @@ sub authenticate {
}
);
unless ( $apacheSession->data ) {
if ( $apacheSession->error ) {
Lemonldap::NG::Handler::Main::Logger->lmLog(
"Session $id can't be retrieved", 'info' );
Lemonldap::NG::Handler::Main::Logger->lmLog( $apacheSession->error,
'info' );
return $self->goToPortal();
}
......
......@@ -31,7 +31,7 @@ use constant MAINTENANCE_CODE => 503;
#inherits Apache::Session
#link Lemonldap::NG::Common::Apache::Session::SOAP protected globalStorage
our $VERSION = '1.4.0';
our $VERSION = '1.4.1';
our %EXPORT_TAGS;
......@@ -204,7 +204,7 @@ sub updateStatus {
print $statusPipe "$user => "
. $apacheRequest->hostname
. "$url $action\n"
if ( $statusPipe );
if ($statusPipe);
};
}
......@@ -367,11 +367,21 @@ sub retrieveSession {
}
);
if ( $datas = $apacheSession->data ) {
unless ( $apacheSession->error ) {
$datas = $apacheSession->data;
# Update the session to notify activity, if necessary
$apacheSession->update( { '_lastSeen' => time } )
if ( $tsv->{timeoutActivity} );
if ( $tsv->{timeoutActivity} ) {
$apacheSession->update( { '_lastSeen' => time } );
if ( $apacheSession->error ) {
Lemonldap::NG::Handler::Main::Logger->lmLog(
"Cannot update session $id", 'error' );
Lemonldap::NG::Handler::Main::Logger->lmLog(
$apacheSession->error, 'error' );
}
}
$datasUpdate = time();
return 1;
......@@ -379,6 +389,9 @@ sub retrieveSession {
else {
Lemonldap::NG::Handler::Main::Logger->lmLog(
"Session $id can't be retrieved", 'info' );
Lemonldap::NG::Handler::Main::Logger->lmLog( $apacheSession->error,
'info' );
return 0;
}
}
......@@ -821,7 +834,7 @@ sub unlog ($$) {
sub status($$) {
my ( $class, $r ) = splice @_;
my $statusOut = $tsv->{statusOut};
my $statusOut = $tsv->{statusOut};
my $statusPipe = $tsv->{statusPipe};
Lemonldap::NG::Handler::Main::Logger->lmLog( "$class: request for status",
......
......@@ -23,7 +23,7 @@ use base qw(Lemonldap::NG::Handler::SharedConf);
use utf8;
no utf8;
our $VERSION = '1.4.0';
our $VERSION = '1.4.1';
# We need just this constant, that's why Portal is 'required' but not 'used'
*PE_OK = *Lemonldap::NG::Portal::SharedConf::PE_OK;
......@@ -144,9 +144,11 @@ sub run ($$) {
}
);
unless ( $apacheSession->data ) {
if ( $apacheSession->error ) {
Lemonldap::NG::Handler::Main::Logger->lmLog(
"The cookie $session_id isn't yet available", 'info' );
Lemonldap::NG::Handler::Main::Logger->lmLog( $apacheSession->error,
'info' );
$class->updateStatus( $class->ip(), $apacheRequest->uri,
'EXPIRED' );
return $class->goToPortal($uri);
......
......@@ -15,7 +15,7 @@ use Lemonldap::NG::Handler::Main::Headers;
use Lemonldap::NG::Handler::Main::Logger;
use Lemonldap::NG::Common::Session;
our $VERSION = '1.4.0';
our $VERSION = '1.4.1';
## @rmethod int run(Apache2::RequestRec apacheRequest)
# Main method used to control access.
......@@ -59,9 +59,11 @@ sub run {
# Get session
else {
unless ( $apacheSession->data ) {
if ( $apacheSession->error ) {
Lemonldap::NG::Handler::Main::Logger->lmLog(
"Session $id can't be retrieved", 'info' );
Lemonldap::NG::Handler::Main::Logger->lmLog(
$apacheSession->error, 'info' );
}
else {
$clear = 1 if ( $apacheSession->data->{_utime} lt $utime );
......
......@@ -72,14 +72,6 @@ sub new {
# Load default skin if no other specified
$self->{managerSkin} ||= 'default';
# Now try to load Apache::Session module
#unless ( $tsv->{globalStorage}->can('populate') ) {
# eval "require $tsv->{globalStorage}";
# $class->abort( "Unable to load $tsv->{globalStorage}", $@ ) if ($@);
#}
#%{ $self->{globalStorageOptions} } = %{$tsv->{globalStorageOptions}};
#$self->{globalStorageOptions}->{backend} = $tsv->{globalStorage};
# IP field
$self->{ipField} = "ipAddr";
......@@ -376,8 +368,9 @@ sub delete {
}
);
unless ( $apacheSession->data ) {
$self->lmLog( "Apache::Session error", 'error' );
if ( $apacheSession->error ) {
$self->lmLog( "Unable to open session $id", 'error' );
$self->lmLog( $apacheSession->error, 'error' );
$res .= '<h1 class="ui-widget-header ui-corner-all">'
. $self->translate('error') . '</h1>';
$res .= '<div class="ui-corner-all ui-widget-content">';
......@@ -400,8 +393,15 @@ sub delete {
}
);
if ( &apacheSession2->data ) {
$apacheSession2->remove;
if ( $apacheSession2->data ) {
unless ( $apacheSession2->remove ) {
$self->lmLog( "Unable to remove session $id2", 'error' );
$self->lmLog( $apacheSession2->error, 'error' );
}
}
else {
$self->lmLog( "Unable to open session $id2", 'error' );
$self->lmLog( $apacheSession2->error, 'error' );
}
}
......@@ -412,6 +412,7 @@ sub delete {
}
else {
$self->lmLog( "Unable to remove session $id", 'error' );
$self->lmLog( $apacheSession->error, 'error' );
$res .= '<h1 class="ui-widget-header ui-corner-all">'
. $self->translate('error') . '</h1>';
$res .= '<div class="ui-corner-all ui-widget-content">';
......@@ -441,9 +442,9 @@ sub session {
}
);
unless ( $apacheSession->data ) {
$self->lmLog( "Apache::Session error", 'error' );
if ( $apacheSession->error ) {
$self->lmLog( "Unable to open session $id", 'error' );
$self->lmLog( $apacheSession->error, 'error' );
$res .= '<h1 class="ui-widget-header ui-corner-all">'
. $self->translate('error') . '</h1>';
$res .= '<div class="ui-corner-all ui-widget-content">';
......
......@@ -71,7 +71,7 @@ use Digest::MD5;
#inherits Apache::Session
#link Lemonldap::NG::Common::Apache::Session::SOAP protected globalStorage
our $VERSION = '1.4.0';
our $VERSION = '1.4.1';
use base qw(Lemonldap::NG::Common::CGI Exporter);
our @ISA;
......@@ -850,7 +850,10 @@ sub getApacheSession {
}
);
return unless $apacheSession->data;
if ( $apacheSession->error ) {
$self->lmLog( $apacheSession->error, 'debug' );
return;
}
unless ($noInfo) {
$self->setApacheUser( $apacheSession->data->{ $self->{whatToTrace} } )
......@@ -880,6 +883,10 @@ sub getPersistentSession {
}
);
if ( $persistentSession->error ) {
$self->lmLog( $persistentSession->error, 'debug' );
}
return $persistentSession;
}
......@@ -916,6 +923,14 @@ sub updatePersistentSession {
$self->getPersistentSession( $self->_md5hash($uid) );
$persistentSession->update($infos);
if ( $persistentSession->error ) {
$self->lmLog(
"Cannot update persistent session " . $self->_md5hash($uid),
'error' );
$self->lmLog( $persistentSession->error, 'error' );
}
}
## @method void updateSession(hashRef infos, string id)
......@@ -960,6 +975,11 @@ sub updateSession {
# Store/update session values
$apacheSession->update($infos);
if ( $apacheSession->error ) {
$self->lmLog( "Cannot update session $id", 'error' );
$self->lmLog( $apacheSession->error, 'error' );
}
}
}
}
......@@ -1197,6 +1217,11 @@ sub _deleteSession {
if ( my $id2 = $session->data->{_httpSession} ) {
if ( my $session2 = $self->getApacheSession( $id2, 1 ) ) {
$session2->remove;
if ( $session2->error ) {
$self->lmLog( "Unable to remove linked session $id2",
'debug' );
$self->lmLog( $session2->error, 'debug' );
}
}
}
......@@ -1232,7 +1257,7 @@ sub _deleteSession {
$self->_sub( 'userNotice', "User $user has been disconnected" )
if $user;
return 1;
return $session->error ? 0 : 1;
}
##@method private void _dump(void* variable)
......@@ -1571,6 +1596,7 @@ sub controlExistingSession {
# Delete session
unless ( $self->_deleteSession($apacheSession) ) {
$self->lmLog( "Unable to delete session $id", 'error' );
$self->lmLog( $apacheSession->error, 'error' );
return PE_ERROR;
}
else {
......
......@@ -10,7 +10,7 @@ use Lemonldap::NG::Portal::_Browser;
use Lemonldap::NG::Common::Session;
our @ISA = (qw(Lemonldap::NG::Portal::_Browser));
our $VERSION = '1.4.0';
our $VERSION = '1.4.1';
## @method hashref getCasSession(string id)
# Try to recover the CAS session corresponding to id and return session datas
......@@ -31,12 +31,13 @@ sub getCasSession {
}
);
unless ( $casSession->data ) {
if ( $casSession->error ) {
if ($id) {
$self->_sub( 'userInfo', "CAS session $id isn't yet available" );
}
else {
$self->lmLog( "Unable to create new CAS session", 'error' );
$self->lmLog( $casSession->error, 'error' );
}
return undef;
}
......@@ -228,7 +229,10 @@ sub deleteCasSession {
my $session_id = $session->id;
# Delete session
$session->remove;
unless ( $session->remove ) {
$self->lmLog( $session->error, 'error' );
return 0;
}
$self->lmLog( "CAS session $session_id deleted", 'debug' );
......
......@@ -10,7 +10,7 @@ use Lemonldap::NG::Portal::Simple;
use Lemonldap::NG::Common::Session;
use MIME::Base64;
our $VERSION = '1.4.0';
our $VERSION = '1.4.1';
our $initDone;
BEGIN {
......@@ -68,8 +68,9 @@ sub checkRemoteId {
}
);
unless ( $remoteSession->data ) {
if ( $remoteSession->error ) {
$self->lmLog( "Remote session error", 'error' );
$self->lmLog( $remoteSession->error, 'error' );
return PE_ERROR;
}
......
......@@ -1238,6 +1238,7 @@ sub extractRelayState {
}
else {
$self->lmLog( "Unable to delete relaystate $relaystate", 'error' );
$self->lmLog( $samlSessionInfo->error, 'error' );
}
return 1;
......@@ -1666,6 +1667,7 @@ sub replayProtection {
"Unable to delete assertion session $session (Message ID $samlID)",
'error'
);
$self->lmLog( $samlSessionInfo->error, 'error' );
return 0;
}
}
......@@ -1800,6 +1802,7 @@ sub loadArtifact {
else {
$self->lmLog( "Unable to delete artifact session $session (ID $id)",
'error' );
$self->lmLog( $samlSessionInfo->error, 'error' );
return;
}
}
......@@ -2831,12 +2834,13 @@ sub getSamlSession {
}
);
unless ( $samlSession->data ) {
if ( $samlSession->error ) {
if ($id) {
$self->_sub( 'userInfo', "SAML session $id isn't yet available" );
}
else {
$self->lmLog( "Unable to create new SAML session", 'error' );
$self->lmLog( $samlSession->error, 'error' );
}
return undef;
}
......@@ -2976,6 +2980,7 @@ sub deleteSAMLSecondarySessions {
else {
$self->lmLog( "Unable to delete SAML session $saml_session",
'error' );
$self->lmLog( $samlSessionInfo->error, "error" );
$result = 0;
}
}
......
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