diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/DefaultValues.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/DefaultValues.pm index de7922fd6..0a17b7608 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/DefaultValues.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Conf/DefaultValues.pm @@ -41,6 +41,7 @@ sub defaultValues { 'checkXSS' => 1, 'confirmFormMethod' => 'post', 'contextSwitchingIdRule' => 1, + 'contextSwitchingPrefix' => 'switching', 'contextSwitchingRule' => 0, 'contextSwitchingStopWithLogout' => 1, 'cookieName' => 'lemonldap', diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm index ae8ff5de1..34edccc3f 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Attributes.pm @@ -1004,6 +1004,10 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.] }, 'type' => 'text' }, + 'contextSwitchingPrefix' => { + 'default' => 'switching', + 'type' => 'text' + }, 'contextSwitchingRule' => { 'default' => 0, 'type' => 'boolOrExpr' diff --git a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build/Attributes.pm b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build/Attributes.pm index 37dab12b2..e5a40f49a 100644 --- a/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build/Attributes.pm +++ b/lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Build/Attributes.pm @@ -550,6 +550,12 @@ sub attributes { documentation => 'Stop context switching by logout', flags => 'p', }, + contextSwitchingPrefix => { + type => 'text', + default => 'switching', + documentation => 'Prefix to store real session Id', + flags => 'p', + }, decryptValueRule => { type => 'boolOrExpr', default => 0, diff --git a/lemonldap-ng-manager/t/80-attributes.t b/lemonldap-ng-manager/t/80-attributes.t index b413726a7..4b9838b52 100644 --- a/lemonldap-ng-manager/t/80-attributes.t +++ b/lemonldap-ng-manager/t/80-attributes.t @@ -66,7 +66,7 @@ my @notManagedAttributes = ( # Other ini-only prms 'checkTime', 'status', 'soapProxyUrn', 'impersonationPrefix', 'pdataDomain', - 'mySessionAuthorizedRWKeys', + 'mySessionAuthorizedRWKeys', 'contextSwitchingPrefix' ); # Words used either as attribute name and node title diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/ContextSwitching.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/ContextSwitching.pm index 9b0af3abf..e5a9f6cca 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/ContextSwitching.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Plugins/ContextSwitching.pm @@ -75,7 +75,7 @@ sub init { sub display { my ( $self, $req ) = @_; my $realSessionId = - $req->userData->{"$self->{conf}->{impersonationPrefix}_session_id"}; + $req->userData->{"$self->{conf}->{contextSwitchingPrefix}_session_id"}; my $realSession; unless ( $realSession = $self->p->getApacheSession($realSessionId) ) { $self->userLogger->info( @@ -85,14 +85,14 @@ sub display { # Check access rules unless ( $self->rule->( $req, $req->userData ) - || $req->userData->{"$self->{conf}->{impersonationPrefix}_session_id"} ) + || $req->userData->{"$self->{conf}->{contextSwitchingPrefix}_session_id"} ) { $self->userLogger->warn('ContextSwitching service NOT authorized'); return $self->p->do( $req, [ sub { PE_IMPERSONATION_SERVICE_NOT_ALLOWED } ] ); } - if ( $req->userData->{"$self->{conf}->{impersonationPrefix}_session_id"} ) { + if ( $req->userData->{"$self->{conf}->{contextSwitchingPrefix}_session_id"} ) { $self->logger->debug('Request to stop ContextSwitching'); if ( $self->conf->{contextSwitchingStopWithLogout} ) { $self->userLogger->notice("Stop ContextSwitching for $req->{user}"); @@ -233,7 +233,7 @@ sub _switchContext { $raz = 1; } - $req->sessionInfo->{"$self->{conf}->{impersonationPrefix}_session_id"} = + $req->sessionInfo->{"$self->{conf}->{contextSwitchingPrefix}_session_id"} = $realSessionId; if ($raz) { @@ -263,7 +263,7 @@ sub _abortImpersonation { my ( $self, $req, $spoofId, $realId, $abort ) = @_; my $type = $abort ? 'sessionInfo' : 'userData'; my $realSessionId = - $req->{$type}->{"$self->{conf}->{impersonationPrefix}_session_id"}; + $req->{$type}->{"$self->{conf}->{contextSwitchingPrefix}_session_id"}; my $session; unless ( $session = $self->p->getApacheSession($realSessionId) ) { $self->userLogger->info("Session $session expired"); @@ -293,7 +293,7 @@ sub _abortImpersonation { $req->urldc( $self->conf->{portal} ); $req->id($realSessionId); $self->p->buildCookie($req); - delete $req->{$type}->{"$self->{conf}->{impersonationPrefix}_session_id"}; + delete $req->{$type}->{"$self->{conf}->{contextSwitchingPrefix}_session_id"}; return $req; } @@ -301,7 +301,7 @@ sub _abortImpersonation { sub displayLink { my ( $self, $req ) = @_; return 'OFF' - if $req->userData->{"$self->{conf}->{impersonationPrefix}_session_id"}; + if $req->userData->{"$self->{conf}->{contextSwitchingPrefix}_session_id"}; return 'ON' if $self->rule->( $req, $req->userData ); } diff --git a/lemonldap-ng-portal/t/68-ContextSwitching-with-Logout.t b/lemonldap-ng-portal/t/68-ContextSwitching-with-Logout.t index eb96f1d81..0bcc30b21 100644 --- a/lemonldap-ng-portal/t/68-ContextSwitching-with-Logout.t +++ b/lemonldap-ng-portal/t/68-ContextSwitching-with-Logout.t @@ -13,19 +13,19 @@ my $client = LLNG::Manager::Test->new( { logLevel => 'error', authentication => 'Demo', userDB => 'Same', + https => 0, loginHistoryEnabled => 0, brutForceProtection => 0, portalMainLogo => 'common/logos/logo_llng_old.png', requireToken => 1, checkUser => 1, - impersonationPrefix => 'testPrefix_', securedCookie => 0, - https => 0, checkUserDisplayPersistentInfo => 0, checkUserDisplayEmptyValues => 0, contextSwitchingRule => 1, contextSwitchingIdRule => 1, contextSwitchingStopWithLogout => 1, + contextSwitchingPrefix => 'testPrefix_', } } ); @@ -109,7 +109,7 @@ ok( ); ok( $res->[2]->[0] =~ -m%
%, + m%
%, 'Found ""' ) or explain( $res->[2]->[0], '' ); count(3);