Append search parameters & improve unit test (#1938)
This commit is contained in:
parent
dc0a8f7848
commit
c34c6e646e
|
@ -807,6 +807,9 @@ qr/(?:(?:https?):\/\/(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.]
|
||||||
},
|
},
|
||||||
'type' => 'text'
|
'type' => 'text'
|
||||||
},
|
},
|
||||||
|
'checkUserSearchAttributes' => {
|
||||||
|
'type' => 'text'
|
||||||
|
},
|
||||||
'checkXSS' => {
|
'checkXSS' => {
|
||||||
'default' => 1,
|
'default' => 1,
|
||||||
'type' => 'bool'
|
'type' => 'bool'
|
||||||
|
|
|
@ -449,6 +449,11 @@ sub attributes {
|
||||||
documentation => 'Attributes to hide in CheckUser plugin',
|
documentation => 'Attributes to hide in CheckUser plugin',
|
||||||
flags => 'p',
|
flags => 'p',
|
||||||
},
|
},
|
||||||
|
checkUserSearchAttributes => {
|
||||||
|
type => 'text',
|
||||||
|
documentation => 'Attributes used for retrieving sessions in user DataBase',
|
||||||
|
flags => 'p',
|
||||||
|
},
|
||||||
checkUserDisplayPersistentInfo => {
|
checkUserDisplayPersistentInfo => {
|
||||||
default => 0,
|
default => 0,
|
||||||
type => 'bool',
|
type => 'bool',
|
||||||
|
|
|
@ -685,6 +685,7 @@ sub tree {
|
||||||
'checkUser',
|
'checkUser',
|
||||||
'checkUserIdRule',
|
'checkUserIdRule',
|
||||||
'checkUserHiddenAttributes',
|
'checkUserHiddenAttributes',
|
||||||
|
'checkUserSearchAttributes',
|
||||||
'checkUserDisplayPersistentInfo',
|
'checkUserDisplayPersistentInfo',
|
||||||
'checkUserDisplayEmptyValues',
|
'checkUserDisplayEmptyValues',
|
||||||
]
|
]
|
||||||
|
|
|
@ -174,6 +174,7 @@
|
||||||
"checkUserHiddenAttributes":"السمات المخفية",
|
"checkUserHiddenAttributes":"السمات المخفية",
|
||||||
"checkUserDisplayPersistentInfo":"Display persistent session",
|
"checkUserDisplayPersistentInfo":"Display persistent session",
|
||||||
"checkUserDisplayEmptyValues":"Display empty values",
|
"checkUserDisplayEmptyValues":"Display empty values",
|
||||||
|
"checkUserSearchAttributes":"Attributes used for searching sessions",
|
||||||
"choiceParams":"اختيارالإعدادات",
|
"choiceParams":"اختيارالإعدادات",
|
||||||
"chooseLogo":"اختيار الشعار",
|
"chooseLogo":"اختيار الشعار",
|
||||||
"chooseSkin":"اختيار الغلاف",
|
"chooseSkin":"اختيار الغلاف",
|
||||||
|
|
|
@ -174,6 +174,7 @@
|
||||||
"checkUserHiddenAttributes":"Hidden attributes",
|
"checkUserHiddenAttributes":"Hidden attributes",
|
||||||
"checkUserDisplayPersistentInfo":"Display persistent session",
|
"checkUserDisplayPersistentInfo":"Display persistent session",
|
||||||
"checkUserDisplayEmptyValues":"Display empty values",
|
"checkUserDisplayEmptyValues":"Display empty values",
|
||||||
|
"checkUserSearchAttributes":"Attributes used for searching sessions",
|
||||||
"choiceParams":"Choice parameters",
|
"choiceParams":"Choice parameters",
|
||||||
"chooseLogo":"Choose logo",
|
"chooseLogo":"Choose logo",
|
||||||
"chooseSkin":"Choose skin",
|
"chooseSkin":"Choose skin",
|
||||||
|
|
|
@ -174,6 +174,7 @@
|
||||||
"checkUserHiddenAttributes":"Hidden attributes",
|
"checkUserHiddenAttributes":"Hidden attributes",
|
||||||
"checkUserDisplayPersistentInfo":"Display persistent session",
|
"checkUserDisplayPersistentInfo":"Display persistent session",
|
||||||
"checkUserDisplayEmptyValues":"Display empty values",
|
"checkUserDisplayEmptyValues":"Display empty values",
|
||||||
|
"checkUserSearchAttributes":"Attributes used for searching sessions",
|
||||||
"choiceParams":"Choice parameters",
|
"choiceParams":"Choice parameters",
|
||||||
"chooseLogo":"Choose logo",
|
"chooseLogo":"Choose logo",
|
||||||
"chooseSkin":"Choose skin",
|
"chooseSkin":"Choose skin",
|
||||||
|
|
|
@ -174,6 +174,7 @@
|
||||||
"checkUserHiddenAttributes":"Attributs masqués",
|
"checkUserHiddenAttributes":"Attributs masqués",
|
||||||
"checkUserDisplayPersistentInfo":"Afficher les données de session persistante",
|
"checkUserDisplayPersistentInfo":"Afficher les données de session persistante",
|
||||||
"checkUserDisplayEmptyValues":"Afficher les valeurs nulles",
|
"checkUserDisplayEmptyValues":"Afficher les valeurs nulles",
|
||||||
|
"checkUserSearchAttributes":"Attributes utilisés pour rechercher les sessions",
|
||||||
"choiceParams":"Paramètres des choix",
|
"choiceParams":"Paramètres des choix",
|
||||||
"chooseLogo":"Choisir le logo",
|
"chooseLogo":"Choisir le logo",
|
||||||
"chooseSkin":"Choisir le thème",
|
"chooseSkin":"Choisir le thème",
|
||||||
|
|
|
@ -174,6 +174,7 @@
|
||||||
"checkUserHiddenAttributes":"Attributi nascosti",
|
"checkUserHiddenAttributes":"Attributi nascosti",
|
||||||
"checkUserDisplayPersistentInfo":"Mostra sessione persistente",
|
"checkUserDisplayPersistentInfo":"Mostra sessione persistente",
|
||||||
"checkUserDisplayEmptyValues":"Mostra valori vuoti",
|
"checkUserDisplayEmptyValues":"Mostra valori vuoti",
|
||||||
|
"checkUserSearchAttributes":"Attributes used for searching sessions",
|
||||||
"choiceParams":"Scelta parametri",
|
"choiceParams":"Scelta parametri",
|
||||||
"chooseLogo":"Scegli logo",
|
"chooseLogo":"Scegli logo",
|
||||||
"chooseSkin":"Scegli interfaccia",
|
"chooseSkin":"Scegli interfaccia",
|
||||||
|
|
|
@ -174,6 +174,7 @@
|
||||||
"checkUserHiddenAttributes":"Thuộc tính ẩn",
|
"checkUserHiddenAttributes":"Thuộc tính ẩn",
|
||||||
"checkUserDisplayPersistentInfo":"Display persistent session",
|
"checkUserDisplayPersistentInfo":"Display persistent session",
|
||||||
"checkUserDisplayEmptyValues":"Display empty values",
|
"checkUserDisplayEmptyValues":"Display empty values",
|
||||||
|
"checkUserSearchAttributes":"Attributes used for searching sessions",
|
||||||
"choiceParams":"Các tham số lựa chọn",
|
"choiceParams":"Các tham số lựa chọn",
|
||||||
"chooseLogo":"Chọn logo",
|
"chooseLogo":"Chọn logo",
|
||||||
"chooseSkin":"Chọn giao diện",
|
"chooseSkin":"Chọn giao diện",
|
||||||
|
|
|
@ -174,6 +174,7 @@
|
||||||
"checkUserHiddenAttributes":"Hidden attributes",
|
"checkUserHiddenAttributes":"Hidden attributes",
|
||||||
"checkUserDisplayPersistentInfo":"Display persistent session",
|
"checkUserDisplayPersistentInfo":"Display persistent session",
|
||||||
"checkUserDisplayEmptyValues":"Display empty values",
|
"checkUserDisplayEmptyValues":"Display empty values",
|
||||||
|
"checkUserSearchAttributes":"Attributes used for searching sessions",
|
||||||
"choiceParams":"Choice parameters",
|
"choiceParams":"Choice parameters",
|
||||||
"chooseLogo":"Choose logo",
|
"chooseLogo":"Choose logo",
|
||||||
"chooseSkin":"Choose skin",
|
"chooseSkin":"Choose skin",
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -40,7 +40,7 @@ sub hAttr {
|
||||||
sub init {
|
sub init {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
my $hd = $self->p->HANDLER;
|
my $hd = $self->p->HANDLER;
|
||||||
$self->addAuthRoute( checkuser => 'check', ['POST'] );
|
$self->addAuthRoute( checkuser => 'check', ['POST'] );
|
||||||
$self->addAuthRouteWithRedirect( checkuser => 'display', ['GET'] );
|
$self->addAuthRouteWithRedirect( checkuser => 'display', ['GET'] );
|
||||||
|
|
||||||
# Parse identity rule
|
# Parse identity rule
|
||||||
|
@ -143,9 +143,17 @@ sub check {
|
||||||
$self->logger->debug('Try to retrieve session from DB...');
|
$self->logger->debug('Try to retrieve session from DB...');
|
||||||
my $moduleOptions = $self->conf->{globalStorageOptions} || {};
|
my $moduleOptions = $self->conf->{globalStorageOptions} || {};
|
||||||
$moduleOptions->{backend} = $self->conf->{globalStorage};
|
$moduleOptions->{backend} = $self->conf->{globalStorage};
|
||||||
my $sessions =
|
|
||||||
$self->module->searchOn( $moduleOptions, $self->conf->{whatToTrace},
|
my $sessions = {};
|
||||||
$user );
|
my $searchAttrs = $self->conf->{checkUserSearchAttributes}
|
||||||
|
|| $self->conf->{whatToTrace};
|
||||||
|
|
||||||
|
foreach ( split /\s+/, $searchAttrs ) {
|
||||||
|
$self->logger->debug("Searching with: $_ = $user");
|
||||||
|
$sessions = $self->module->searchOn( $moduleOptions, $_, $user );
|
||||||
|
last if (keys %$sessions);
|
||||||
|
}
|
||||||
|
|
||||||
my $age = '1';
|
my $age = '1';
|
||||||
foreach my $id ( keys %$sessions ) {
|
foreach my $id ( keys %$sessions ) {
|
||||||
my $session = $self->p->getApacheSession($id) or next;
|
my $session = $self->p->getApacheSession($id) or next;
|
||||||
|
@ -272,7 +280,7 @@ sub check {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub display {
|
sub display {
|
||||||
my ( $self, $req ) = @_;
|
my ( $self, $req ) = @_;
|
||||||
my ( $attrs, $array_attrs ) = ( {}, [] );
|
my ( $attrs, $array_attrs ) = ( {}, [] );
|
||||||
|
|
||||||
$self->logger->debug("Display current session data...");
|
$self->logger->debug("Display current session data...");
|
||||||
|
|
|
@ -10,14 +10,15 @@ my $res;
|
||||||
|
|
||||||
my $client = LLNG::Manager::Test->new( {
|
my $client = LLNG::Manager::Test->new( {
|
||||||
ini => {
|
ini => {
|
||||||
logLevel => 'error',
|
logLevel => 'error',
|
||||||
authentication => 'Demo',
|
authentication => 'Demo',
|
||||||
userDB => 'Same',
|
userDB => 'Same',
|
||||||
loginHistoryEnabled => 0,
|
loginHistoryEnabled => 0,
|
||||||
brutForceProtection => 0,
|
brutForceProtection => 0,
|
||||||
checkUser => 1,
|
checkUser => 1,
|
||||||
requireToken => 0,
|
requireToken => 0,
|
||||||
checkUserIdRule => '$uid ne "msmith"',
|
checkUserIdRule => '$uid ne "msmith"',
|
||||||
|
checkUserSearchAttributes => 'employee_nbr test1 _user test2 mail',
|
||||||
checkUserDisplayPersistentInfo => 1,
|
checkUserDisplayPersistentInfo => 1,
|
||||||
checkUserDisplayEmptyValues => 1,
|
checkUserDisplayEmptyValues => 1,
|
||||||
totp2fSelfRegistration => 1,
|
totp2fSelfRegistration => 1,
|
||||||
|
@ -239,8 +240,40 @@ ok( $res->[2]->[0] =~ m%<td scope="row">dwho</td>%, 'Found dwho' )
|
||||||
or explain( $res->[2]->[0], 'Macro Value dwho' );
|
or explain( $res->[2]->[0], 'Macro Value dwho' );
|
||||||
count(3);
|
count(3);
|
||||||
|
|
||||||
|
# Request with mail
|
||||||
|
$query =~ s/user=dwho/user=dwho%40badwolf.org/;
|
||||||
|
ok(
|
||||||
|
$res = $client->_post(
|
||||||
|
'/checkuser',
|
||||||
|
IO::String->new($query),
|
||||||
|
cookie => "lemonldap=$id",
|
||||||
|
length => length($query),
|
||||||
|
accept => 'text/html',
|
||||||
|
),
|
||||||
|
'POST checkuser'
|
||||||
|
);
|
||||||
|
count(1);
|
||||||
|
|
||||||
|
( $host, $url, $query ) =
|
||||||
|
expectForm( $res, undef, '/checkuser', 'user', 'url' );
|
||||||
|
ok( $res->[2]->[0] =~ m%<span trspan="checkUser">%, 'Found trspan="checkUser"' )
|
||||||
|
or explain( $res->[2]->[0], 'trspan="checkUser"' );
|
||||||
|
ok( $res->[2]->[0] =~ m%value="dwho\@badwolf.org" trplaceholder="user"%, 'Found trplaceholder with mail' )
|
||||||
|
or explain( $res->[2]->[0], 'trplaceholder with mail' );
|
||||||
|
count(3);
|
||||||
|
ok( $res->[2]->[0] =~ m%Auth-User: %, 'Found Auth-User' )
|
||||||
|
or explain( $res->[2]->[0], 'Header Key: Auth-User' );
|
||||||
|
ok( $res->[2]->[0] =~ m%: dwho<br/>%, 'Found dwho' )
|
||||||
|
or explain( $res->[2]->[0], 'Header Value: dwho' );
|
||||||
|
ok( $res->[2]->[0] =~ m%<td scope="row">_whatToTrace</td>%,
|
||||||
|
'Found _whatToTrace' )
|
||||||
|
or explain( $res->[2]->[0], 'Macro Key _whatToTrace' );
|
||||||
|
ok( $res->[2]->[0] =~ m%<td scope="row">dwho</td>%, 'Found dwho' )
|
||||||
|
or explain( $res->[2]->[0], 'Macro Value dwho' );
|
||||||
|
count(3);
|
||||||
|
|
||||||
# Request with bad VH
|
# Request with bad VH
|
||||||
$query =~ s/user=dwho/user=rtyler/;
|
$query =~ s/user=dwho%40badwolf.org/user=rtyler/;
|
||||||
$query =~
|
$query =~
|
||||||
s/url=http%3A%2F%2Ftest1.example.com/url=http%3A%2F%2Ftry.example.com/;
|
s/url=http%3A%2F%2Ftest1.example.com/url=http%3A%2F%2Ftry.example.com/;
|
||||||
ok(
|
ok(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user