Fix speChars test, typos & display (#2509)

This commit is contained in:
Christophe Maudoux 2021-04-14 13:15:26 +02:00
parent fbd99f8a7f
commit 21ced5dbad
5 changed files with 20 additions and 18 deletions

View File

@ -346,8 +346,7 @@ Password Policy
- **Minimal upper characters**: leave 0 to bypass the check
- **Minimal digit characters**: leave 0 to bypass the check
- **Minimal special characters**: leave 0 to bypass the check
- **Allowed special characters**: set blanck to forbid special
characters (``_`` is not a special character)
- **Allowed special characters**: set '__ALL__' value to allow ALL special characters. A blanck value forbids ALL special characters (Note that ``_`` is not a special character)
- **Display policy in password form**: enable this to display an
information message about password policy constraints

View File

@ -759,9 +759,9 @@
"passwordPolicyMinDigit":"Minimum de chiffres",
"passwordPolicyMinLower":"Minimum de minuscules",
"passwordPolicyMinSize":"Taille minimale",
"passwordPolicyMinSpeChar":"Minimum de caractètes spéciaux",
"passwordPolicyMinSpeChar":"Minimum de caractères spéciaux",
"passwordPolicyMinUpper":"Minimum de majuscules",
"passwordPolicySpecialChar":"Caractètes spéciaux autorisés",
"passwordPolicySpecialChar":"Caractères spéciaux autorisés",
"passwordResetAllowedRetries":"Nombre d'essais pour réinitialiser le mot de passe",
"persistent":"Persistantes",
"persistentSessions":"Sessions persistantes",

View File

@ -2,7 +2,7 @@
# Display functions for LemonLDAP::NG Portal
package Lemonldap::NG::Portal::Main::Display;
our $VERSION = '2.0.11';
our $VERSION = '2.0.12';
package Lemonldap::NG::Portal::Main;
use strict;
@ -53,6 +53,7 @@ sub displayInit {
|| $self->conf->{passwordPolicyMinLower}
|| $self->conf->{passwordPolicyMinUpper}
|| $self->conf->{passwordPolicyMinDigit}
|| $self->conf->{passwordPolicyMinSpeChar}
|| $speChars;
$self->isPP($isPP);
}
@ -252,7 +253,7 @@ sub display {
PPOLICY_MINDIGIT => $self->conf->{passwordPolicyMinDigit},
PPOLICY_MINSPECHAR => $self->conf->{passwordPolicyMinSpeChar},
(
$self->conf->{passwordPolicyMinSpeChar}
$self->conf->{passwordPolicyMinSpeChar} || $self->speChars()
? ( PPOLICY_ALLOWEDSPECHAR => $self->speChars() )
: ()
),
@ -449,7 +450,7 @@ sub display {
PPOLICY_MINDIGIT => $self->conf->{passwordPolicyMinDigit},
PPOLICY_MINSPECHAR => $self->conf->{passwordPolicyMinSpeChar},
(
$self->conf->{passwordPolicyMinSpeChar}
$self->conf->{passwordPolicyMinSpeChar} || $self->speChars()
? ( PPOLICY_ALLOWEDSPECHAR => $self->speChars() )
: ()
),

View File

@ -17,7 +17,7 @@ use Lemonldap::NG::Portal::Main::Constants qw(
extends 'Lemonldap::NG::Portal::Main::Plugin';
our $VERSION = '2.0.10';
our $VERSION = '2.0.12';
# INITIALIZATION
@ -195,14 +195,16 @@ sub checkPasswordQuality {
}
## Fobidden special characters
$password =~ s/[\Q$speChars\E\w]//g;
if ($password) {
$self->logger->error( 'Password contains '
. length($password)
. " forbidden character(s): $password" );
return length($password) > 1
? PE_PP_NOT_ALLOWED_CHARACTERS
: PE_PP_NOT_ALLOWED_CHARACTER;
unless ( $speChars eq '__ALL__' ) {
$password =~ s/[\Q$speChars\E\w]//g;
if ($password) {
$self->logger->error( 'Password contains '
. length($password)
. " forbidden character(s): $password" );
return length($password) > 1
? PE_PP_NOT_ALLOWED_CHARACTERS
: PE_PP_NOT_ALLOWED_CHARACTER;
}
}
return PE_OK;

View File

@ -48,8 +48,8 @@ ok(
ok( $res->[2]->[0] =~ m%<input id="oldpassword" name="oldpassword"%,
' Old password input' )
or print STDERR Dumper( $res->[2]->[0] );
ok( $res->[2]->[0] =~ m%<span trspan="passwordPolicyNone">%,
' passwordPolicyNone' )
ok( $res->[2]->[0] =~ m%<span trspan="passwordPolicyMinSpeChar">Minimal special characters:</span> 2%,
' passwordPolicyMinSpeChar' )
or print STDERR Dumper( $res->[2]->[0] );
count(3);