Add filter on _session_kind (Closes: #1043)
This commit is contained in:
parent
41e2be351f
commit
d5b5c57595
|
@ -133,7 +133,7 @@
|
||||||
.\" ========================================================================
|
.\" ========================================================================
|
||||||
.\"
|
.\"
|
||||||
.IX Title "llng-fastcgi-server 1"
|
.IX Title "llng-fastcgi-server 1"
|
||||||
.TH llng-fastcgi-server 1 "2016-06-09" "perl v5.22.2" "User Contributed Perl Documentation"
|
.TH llng-fastcgi-server 1 "2016-06-26" "perl v5.22.2" "User Contributed Perl Documentation"
|
||||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||||
.\" way too many mistakes in technical documents.
|
.\" way too many mistakes in technical documents.
|
||||||
.if n .ad l
|
.if n .ad l
|
||||||
|
|
|
@ -59,7 +59,7 @@ sub addRoutes {
|
||||||
$self->{ $type . 'StorageOptions' }
|
$self->{ $type . 'StorageOptions' }
|
||||||
|| $conf->{ $type . 'StorageOptions' }
|
|| $conf->{ $type . 'StorageOptions' }
|
||||||
|| {};
|
|| {};
|
||||||
$self->{conf}->{kind} =
|
$self->{conf}->{$type}->{kind} =
|
||||||
( $type eq 'global' ? 'SSO' : ucfirst($type) );
|
( $type eq 'global' ? 'SSO' : ucfirst($type) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,8 @@ sub sessions {
|
||||||
my $mod = $self->getMod($req)
|
my $mod = $self->getMod($req)
|
||||||
or return $self->sendError( $req, undef, 400 );
|
or return $self->sendError( $req, undef, 400 );
|
||||||
my $params = $req->params();
|
my $params = $req->params();
|
||||||
delete $params->{sessionType};
|
my $type = delete $params->{sessionType};
|
||||||
|
$type = $type eq 'global' ? 'SSO' : ucfirst($type);
|
||||||
|
|
||||||
my $res;
|
my $res;
|
||||||
|
|
||||||
|
@ -113,52 +114,46 @@ sub sessions {
|
||||||
# not a keyword)
|
# not a keyword)
|
||||||
my $moduleOptions = $mod->{options};
|
my $moduleOptions = $mod->{options};
|
||||||
$moduleOptions->{backend} = $mod->{module};
|
$moduleOptions->{backend} = $mod->{module};
|
||||||
if (
|
my %filters = map {
|
||||||
my %filters = map {
|
my $s = $_;
|
||||||
my $s = $_;
|
$s =~ s/\b_whatToTrace\b/$whatToTrace/o;
|
||||||
s/\b_whatToTrace\b/$whatToTrace/o;
|
/^(?:(?:group|order)By|doubleIp)$/
|
||||||
/^(?:(?:group|order)By|doubleIp)$/
|
? ()
|
||||||
? ()
|
: ( $s => $params->{$_} );
|
||||||
: ( $_ => $params->{$s} );
|
} keys %$params;
|
||||||
} keys %$params
|
$filters{_session_kind} = $type;
|
||||||
)
|
|
||||||
{
|
|
||||||
|
|
||||||
# Check if a '*' is required
|
# Check if a '*' is required
|
||||||
my $function = 'searchOn';
|
my $function = 'searchOn';
|
||||||
$function = 'searchOnExpr' if ( grep /\*/, values %filters );
|
$function = 'searchOnExpr' if ( grep /\*/, values %filters );
|
||||||
|
|
||||||
# For now, only one argument can be passed to
|
# For now, only one argument can be passed to
|
||||||
# Lemonldap::NG::Common::Apache::Session so just the first filter is
|
# Lemonldap::NG::Common::Apache::Session so just the first filter is
|
||||||
# used
|
# used
|
||||||
my ($firstFilter) = keys %filters;
|
my ($firstFilter) = sort {
|
||||||
$res =
|
$a eq '_session_kind' ? 1
|
||||||
Lemonldap::NG::Common::Apache::Session->$function( $moduleOptions,
|
: $b eq '_session_kind' ? -1
|
||||||
$firstFilter, $filters{$firstFilter}, @fields );
|
: $a cmp $b
|
||||||
|
} keys %filters;
|
||||||
|
$res =
|
||||||
|
Lemonldap::NG::Common::Apache::Session->$function( $moduleOptions,
|
||||||
|
$firstFilter, $filters{$firstFilter}, @fields );
|
||||||
|
|
||||||
# TODO: change this
|
# TODO: change this
|
||||||
return $self->sendError( $req, 'No sessions', 200 )
|
return $self->sendError( $req, 'No sessions', 200 )
|
||||||
unless ( $res and %$res );
|
unless ( $res and %$res );
|
||||||
delete $filters{$firstFilter};
|
delete $filters{$firstFilter};
|
||||||
foreach my $k ( keys %filters ) {
|
foreach my $k ( keys %filters ) {
|
||||||
$filters{$k} =~ s/\*/\.\*/g;
|
$filters{$k} =~ s/\*/\.\*/g;
|
||||||
foreach my $session ( keys %$res ) {
|
foreach my $session ( keys %$res ) {
|
||||||
if ( $res->{$session}->{$k} ) {
|
if ( $res->{$session}->{$k} ) {
|
||||||
delete $res->{$session}
|
delete $res->{$session}
|
||||||
unless ( $res->{$session}->{$k} =~ /^$filters{$k}$/ );
|
unless ( $res->{$session}->{$k} =~ /^$filters{$k}$/ );
|
||||||
print STDERR "Deleted\n";
|
print STDERR "Deleted\n";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# 2.3 Else get all sessions
|
|
||||||
else {
|
|
||||||
$res =
|
|
||||||
Lemonldap::NG::Common::Apache::Session->get_key_from_all_sessions(
|
|
||||||
$moduleOptions, [@fields] );
|
|
||||||
}
|
|
||||||
|
|
||||||
my $total = ( keys %$res );
|
my $total = ( keys %$res );
|
||||||
|
|
||||||
# 2.4 Special case doubleIp (users connected from more than 1 IP)
|
# 2.4 Special case doubleIp (users connected from more than 1 IP)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user