Append customParam to globalLogout plugin (#2145)

This commit is contained in:
Christophe Maudoux 2020-04-11 22:34:29 +02:00
parent 3a4ab3bbec
commit 082d12ca5f
16 changed files with 60 additions and 28 deletions

View File

@ -1294,6 +1294,9 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
'default' => 120, 'default' => 120,
'type' => 'int' 'type' => 'int'
}, },
'globalLogoutCustomParam' => {
'type' => 'text'
},
'globalLogoutRule' => { 'globalLogoutRule' => {
'default' => 0, 'default' => 0,
'type' => 'boolOrExpr' 'type' => 'boolOrExpr'

View File

@ -494,6 +494,11 @@ sub attributes {
documentation => 'Global logout auto accept time', documentation => 'Global logout auto accept time',
flags => 'p', flags => 'p',
}, },
globalLogoutCustomParam => {
type => 'text',
documentation => 'Custom session parameter to display',
flags => 'p',
},
impersonationMergeSSOgroups => { impersonationMergeSSOgroups => {
default => 0, default => 0,
type => 'boolOrExpr', type => 'boolOrExpr',

View File

@ -709,7 +709,7 @@ sub tree {
help => 'globallogout.html', help => 'globallogout.html',
form => 'simpleInputContainer', form => 'simpleInputContainer',
nodes => nodes =>
[ 'globalLogoutRule', 'globalLogoutTimer', ], [ 'globalLogoutRule', 'globalLogoutTimer','globalLogoutCustomParam' ],
}, },
{ {
title => 'stateCheck', title => 'stateCheck',

View File

@ -317,6 +317,7 @@
"friendlyName":"اسم مألوف", "friendlyName":"اسم مألوف",
"generalParameters":"المعاييرالعامة", "generalParameters":"المعاييرالعامة",
"globalLogout":"Global logout", "globalLogout":"Global logout",
"globalLogoutCustomParam":"Custom parameter",
"globalLogoutRule":"تفعيل", "globalLogoutRule":"تفعيل",
"globalLogoutTimer":"قبول تلقائي للوقت", "globalLogoutTimer":"قبول تلقائي للوقت",
"globalStorage":"أباتشي :: وحدة الجلسة", "globalStorage":"أباتشي :: وحدة الجلسة",

View File

@ -317,6 +317,7 @@
"friendlyName":"Friendly name", "friendlyName":"Friendly name",
"generalParameters":"General Parameters", "generalParameters":"General Parameters",
"globalLogout":"Global logout", "globalLogout":"Global logout",
"globalLogoutCustomParam":"Custom parameter",
"globalLogoutRule":"Activation", "globalLogoutRule":"Activation",
"globalLogoutTimer":"Auto accept time", "globalLogoutTimer":"Auto accept time",
"globalStorage":"Apache::Session module", "globalStorage":"Apache::Session module",

View File

@ -317,6 +317,7 @@
"friendlyName":"Friendly name", "friendlyName":"Friendly name",
"generalParameters":"General Parameters", "generalParameters":"General Parameters",
"globalLogout":"Global logout", "globalLogout":"Global logout",
"globalLogoutCustomParam":"Custom parameter",
"globalLogoutRule":"Activation", "globalLogoutRule":"Activation",
"globalLogoutTimer":"Auto accept time", "globalLogoutTimer":"Auto accept time",
"globalStorage":"Apache::Session module", "globalStorage":"Apache::Session module",

View File

@ -317,6 +317,7 @@
"friendlyName":"Nom alternatif", "friendlyName":"Nom alternatif",
"generalParameters":"Paramètres généraux", "generalParameters":"Paramètres généraux",
"globalLogout":"Déconnexion globale", "globalLogout":"Déconnexion globale",
"globalLogoutCustomParam":"Paramètre personnalisé",
"globalLogoutRule":"Activation", "globalLogoutRule":"Activation",
"globalLogoutTimer":"Délai d'acceptation automatique", "globalLogoutTimer":"Délai d'acceptation automatique",
"globalStorage":"Module Apache::Session", "globalStorage":"Module Apache::Session",

View File

@ -317,6 +317,7 @@
"friendlyName":"Nome amichevole", "friendlyName":"Nome amichevole",
"generalParameters":"Parametri generali", "generalParameters":"Parametri generali",
"globalLogout":"Global logout", "globalLogout":"Global logout",
"globalLogoutCustomParam":"Custom parameter",
"globalLogoutRule":"Attivazione", "globalLogoutRule":"Attivazione",
"globalLogoutTimer":"Auto accettazione tempo", "globalLogoutTimer":"Auto accettazione tempo",
"globalStorage":"Modulo Apache::Session", "globalStorage":"Modulo Apache::Session",

View File

@ -317,6 +317,7 @@
"friendlyName":"Kolay ad", "friendlyName":"Kolay ad",
"generalParameters":"Genel Parametreler", "generalParameters":"Genel Parametreler",
"globalLogout":"Global çıkış", "globalLogout":"Global çıkış",
"globalLogoutCustomParam":"Custom parameter",
"globalLogoutRule":"Aktivasyon", "globalLogoutRule":"Aktivasyon",
"globalLogoutTimer":"Otomatik kabul süresi", "globalLogoutTimer":"Otomatik kabul süresi",
"globalStorage":"Apache::Session modülü", "globalStorage":"Apache::Session modülü",

View File

@ -317,6 +317,7 @@
"friendlyName":"Tên thân thiện", "friendlyName":"Tên thân thiện",
"generalParameters":"Thông số chung", "generalParameters":"Thông số chung",
"globalLogout":"Global logout", "globalLogout":"Global logout",
"globalLogoutCustomParam":"Custom parameter",
"globalLogoutRule":"Activation", "globalLogoutRule":"Activation",
"globalLogoutTimer":"Tự động chấp nhận thời gian", "globalLogoutTimer":"Tự động chấp nhận thời gian",
"globalStorage":"Mô đun Apache :: Session", "globalStorage":"Mô đun Apache :: Session",

View File

@ -317,6 +317,7 @@
"friendlyName":"Friendly name", "friendlyName":"Friendly name",
"generalParameters":"通用参数", "generalParameters":"通用参数",
"globalLogout":"Global logout", "globalLogout":"Global logout",
"globalLogoutCustomParam":"Custom parameter",
"globalLogoutRule":"Activation", "globalLogoutRule":"Activation",
"globalLogoutTimer":"自动接收时间", "globalLogoutTimer":"自动接收时间",
"globalStorage":"Apache::Session 模块", "globalStorage":"Apache::Session 模块",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -11,7 +11,7 @@ use Lemonldap::NG::Portal::Main::Constants qw(
PE_SENDRESPONSE PE_SENDRESPONSE
); );
our $VERSION = '2.0.7'; our $VERSION = '2.0.8';
extends qw( extends qw(
Lemonldap::NG::Portal::Main::Plugin Lemonldap::NG::Portal::Main::Plugin
@ -55,7 +55,7 @@ sub init {
} }
# RUNNING METHODS # RUNNING METHODS
# Look for user active SSO sessions and propose to close them # Look for user active SSO sessions and suggest to close them
sub run { sub run {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;
my $user = $req->{userData}->{ $self->conf->{whatToTrace} }; my $user = $req->{userData}->{ $self->conf->{whatToTrace} };
@ -102,6 +102,7 @@ sub run {
SESSIONS => $sessions, SESSIONS => $sessions,
TOKEN => $token, TOKEN => $token,
LOGIN => $user, LOGIN => $user,
CUSTOMPRM => $self->conf->{globalLogoutCustomParam}
} }
); );
$req->response($tmp); $req->response($tmp);
@ -168,10 +169,12 @@ sub activeSessions {
my ( $self, $req ) = @_; my ( $self, $req ) = @_;
my $activeSessions = []; my $activeSessions = [];
my $sessions = {}; my $sessions = {};
my $regex = '^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$';
my $user = $req->{userData}->{ $self->conf->{whatToTrace} }; my $user = $req->{userData}->{ $self->conf->{whatToTrace} };
my $customParam = $self->conf->{globalLogoutCustomParam} || '';
# Try to retrieve session from sessions DB # Try to retrieve sessions from sessions DB
$self->logger->debug('Try to retrieve session from DB'); $self->logger->debug('Try to retrieve sessions from DB');
my $moduleOptions = $self->conf->{globalStorageOptions} || {}; my $moduleOptions = $self->conf->{globalStorageOptions} || {};
$moduleOptions->{backend} = $self->conf->{globalStorage}; $moduleOptions->{backend} = $self->conf->{globalStorage};
$self->logger->debug("Looking for \"$user\" sessions..."); $self->logger->debug("Looking for \"$user\" sessions...");
@ -182,11 +185,17 @@ sub activeSessions {
$self->logger->debug("Building array ref with sessions info..."); $self->logger->debug("Building array ref with sessions info...");
@$activeSessions = map { { @$activeSessions = map { {
id => $_, id => $_,
UA => $sessions->{$_}->{'UA'}, customParam => $sessions->{$_}->{$customParam},
ipAddr => $sessions->{$_}->{'ipAddr'}, ipAddr => $sessions->{$_}->{'ipAddr'},
authLevel => $sessions->{$_}->{'authenticationLevel'}, authLevel => $sessions->{$_}->{'authenticationLevel'},
startTime => $sessions->{$_}->{'_startTime'}, startTime => $sessions->{$_}->{'_startTime'} =~
updateTime => $sessions->{$_}->{'_updateTime'}, s/$regex/$1-$2-$3 $4:$5:$6/ro,
updateTime => (
$sessions->{$_}->{'_updateTime'}
? $sessions->{$_}->{'_updateTime'} =~
s/$regex/$1-$2-$3 $4:$5:$6/ro
: ''
),
}; };
} keys %$sessions; } keys %$sessions;

View File

@ -7,14 +7,16 @@
<TMPL_IF NAME="SESSIONS"> <TMPL_IF NAME="SESSIONS">
<div class="card col border-secondary"> <div class="card col border-secondary">
<div class="text-center bg-light text-dark"><b><span trspan="activeSessions">ACTIVE SSO SESSIONS</span>: <u><TMPL_VAR NAME="LOGIN"></u></b></div> <div class="text-center bg-light text-dark"><b><span trspan="activeSessions">ACTIVE SSO SESSIONS</span>: <u><TMPL_VAR NAME="LOGIN"></u></b></div>
<table class="table table-sm table-hover"> <table class="table table-sm table-hover text-center">
<thead> <thead>
<tr> <tr>
<th scope="col"><span trspan="startTime">startTime</span></th> <th scope="col"><span trspan="startTime">startTime</span></th>
<th scope="col"><span trspan="updateTime">updateTime</span></th> <th scope="col"><span trspan="updateTime">updateTime</span></th>
<th scope="col"><span trspan="authLevel">authLevel</span></th>
<th scope="col"><span trspan="ipAddr">ipAddr</span></th> <th scope="col"><span trspan="ipAddr">ipAddr</span></th>
<th scope="col"><span trspan="UA">UA</span></th> <th scope="col"><span trspan="authLevel">authLevel</span></th>
<TMPL_IF NAME="CUSTOMPRM">
<th scope="col"><TMPL_VAR NAME="CUSTOMPRM"></th>
</TMPL_IF>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -22,9 +24,11 @@
<tr> <tr>
<td scope="row"><TMPL_VAR NAME="startTime"></td> <td scope="row"><TMPL_VAR NAME="startTime"></td>
<td scope="row"><TMPL_VAR NAME="updateTime"></td> <td scope="row"><TMPL_VAR NAME="updateTime"></td>
<td scope="row"><TMPL_VAR NAME="authLevel"></td>
<td scope="row"><TMPL_VAR NAME="ipAddr"></td> <td scope="row"><TMPL_VAR NAME="ipAddr"></td>
<td scope="row"><TMPL_VAR NAME="UA"></td> <td scope="row"><TMPL_VAR NAME="authLevel"></td>
<TMPL_IF NAME="CUSTOMPRM">
<td scope="row"><TMPL_VAR NAME="customParam"></td>
</TMPL_IF>
</tr> </tr>
</TMPL_LOOP> </TMPL_LOOP>
</tbody> </tbody>

View File

@ -19,6 +19,7 @@ my $client = LLNG::Manager::Test->new( {
requireToken => 0, requireToken => 0,
restSessionServer => 1, restSessionServer => 1,
globalLogoutRule => '$uid eq "dwho"', globalLogoutRule => '$uid eq "dwho"',
globalLogoutCustomParam => 'authMode'
} }
} }
); );
@ -138,15 +139,17 @@ my ( $host, $url, $query ) =
ok( $res->[2]->[0] =~ m%<span trspan="globalLogout">%, ok( $res->[2]->[0] =~ m%<span trspan="globalLogout">%,
'Found trspan="globalLogout"' ) 'Found trspan="globalLogout"' )
or explain( $res->[2]->[0], 'trspan="globalLogout"' ); or explain( $res->[2]->[0], 'trspan="globalLogout"' );
ok( $res->[2]->[0] =~ m%<td scope="row">DEMO</td>%, 'CustomParam found "DEMO"' )
or explain( $res->[2]->[0], 'CustomParam DEMO' );
my @c = ( $res->[2]->[0] =~ m%<td scope="row">127.0.0.1</td>%gs ); my @c = ( $res->[2]->[0] =~ m%<td scope="row">127.0.0.1</td>%gs );
my @d = ( $res->[2]->[0] =~ m%<th scope="col"><span trspan="%gs ); my @d = ( $res->[2]->[0] =~ m%<th scope="col">%gs );
## Three entries found ## Three entries found
ok( @c == 3, ' -> Three entries found' ) ok( @c == 3, ' -> Three entries found' )
or explain( $res->[2]->[0], "Number of session(s) found = " . scalar @c ); or explain( $res->[2]->[0], "Number of session(s) found = " . scalar @c );
ok( @d == 5, ' -> Five <th> found' ) ok( @d == 5, ' -> Five <th> found' )
or explain( $res->[2]->[0], "Number of <th> found = " . scalar @d ); or explain( $res->[2]->[0], "Number of <th> found = " . scalar @d );
count(3); count(4);
## GlobalLogout request for 'dwho' ## GlobalLogout request for 'dwho'
$query .= '&all=1'; $query .= '&all=1';