diff --git a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm index 2f37e72a7..eba7d0b69 100644 --- a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm +++ b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm @@ -1147,6 +1147,7 @@ sub setSessionInfo { $xheader =~ s/(.*?)(\,)+.*/$1/ if $xheader; $self->{sessionInfo}->{xForwardedForAddr} = $xheader || $ENV{REMOTE_ADDR}; + # Date and time if ( $self->{updateSession} ) { $self->{sessionInfo}->{updateTime} = &POSIX::strftime( "%Y%m%d%H%M%S", localtime() ); @@ -1156,6 +1157,17 @@ sub setSessionInfo { $self->{sessionInfo}->{startTime} = &POSIX::strftime( "%Y%m%d%H%M%S", localtime() ); } + + # Get environment variables matching exportedVars + foreach ( keys %{ $self->{exportedVars} } ) { + if ( my $tmp = $ENV{ $self->{exportedVars}->{$_} } ) { + $tmp =~ s/[\r\n]/ /gs; + $self->{sessionInfo}->{$_} = $tmp; + delete $self->{exportedVars}->{$_}; + } + } + + # Call UserDB setSessionInfo return $self->SUPER::setSessionInfo(); } diff --git a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBEnv.pm b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBEnv.pm deleted file mode 100644 index bb89fca12..000000000 --- a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBEnv.pm +++ /dev/null @@ -1,59 +0,0 @@ -## @file -# Env userDB mechanism - -## @class -# Env userDB mechanism class -package Lemonldap::NG::Portal::UserDBEnv; - -use strict; -use Lemonldap::NG::Portal::Simple; - -our $VERSION = '0.1'; - -## @apmethod int userDBInit() -# Do nothing -# @return Lemonldap::NG::Portal constant -sub userDBInit { - PE_OK; -} - -## @apmethod int getUser() -# Do nothing -# @return Lemonldap::NG::Portal constant -sub getUser { - PE_OK; -} - -## @apmethod int setSessionInfo() -# Fetch all environment variables declared in exportedVars -# @return Lemonldap::NG::Portal constant -sub setSessionInfo { - my $self = shift; - - # Check access to %ENV - unless ( defined %ENV ) { - $self->lmLog( "No environment variables available", 'error' ); - return PE_ERROR; - } - - # Parse exportedVars - if ( ref( $self->{exportedVars} ) eq 'HASH' ) { - foreach ( keys %{ $self->{exportedVars} } ) { - if ( exists $ENV{ $self->{exportedVars}->{$_} } ) { - $self->{sessionInfo}->{$_} = - $ENV{ $self->{exportedVars}->{$_} }; - } - } - } - - PE_OK; -} - -## @apmethod int setGroups() -# Do nothing -# @return Lemonldap::NG::Portal constant -sub setGroups { - PE_OK; -} -1; - diff --git a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBLDAP.pm b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBLDAP.pm index dfdf8a2f8..ab503a94c 100644 --- a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBLDAP.pm +++ b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBLDAP.pm @@ -100,20 +100,12 @@ sub setSessionInfo { } elsif ( ref( $self->{exportedVars} ) eq 'HASH' ) { foreach ( keys %{ $self->{exportedVars} } ) { - - # Special code to catch env var - if ( my $tmp = $ENV{$_} ) { - $tmp =~ s/[\r\n]/ /gs; - $self->{sessionInfo}->{$_} = $tmp; - } - else { $self->{sessionInfo}->{$_} = $self->{ldap} ->getLdapValue( $self->{entry}, $self->{exportedVars}->{$_} ) || ""; } } - } else { $self->abort('Only hash reference are supported now in exportedVars'); } diff --git a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBNull.pm b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBNull.pm index f16f553cf..e4cc80217 100644 --- a/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBNull.pm +++ b/modules/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/UserDBNull.pm @@ -28,7 +28,6 @@ sub getUser { # Do nothing # @return Lemonldap::NG::Portal constant sub setSessionInfo { - my $self = shift; PE_OK; } @@ -38,5 +37,6 @@ sub setSessionInfo { sub setGroups { PE_OK; } + 1;