Allow all special chars (#2266)

This commit is contained in:
Christophe Maudoux 2020-08-29 22:12:09 +02:00
parent 7a9020ff25
commit 01beb5d48b
5 changed files with 54 additions and 20 deletions

View File

@ -2,7 +2,7 @@
# Display functions for LemonLDAP::NG Portal # Display functions for LemonLDAP::NG Portal
package Lemonldap::NG::Portal::Main::Display; package Lemonldap::NG::Portal::Main::Display;
our $VERSION = '2.0.9'; our $VERSION = '2.0.10';
package Lemonldap::NG::Portal::Main; package Lemonldap::NG::Portal::Main;
use strict; use strict;
@ -40,7 +40,10 @@ sub displayInit {
} }
$self->requireOldPwd($rule); $self->requireOldPwd($rule);
my $speChars = $self->conf->{passwordPolicySpecialChar}; my $speChars =
$self->conf->{passwordPolicySpecialChar} eq '__ALL__'
? ''
: $self->conf->{passwordPolicySpecialChar};
$speChars =~ s/\s+/ /g; $speChars =~ s/\s+/ /g;
$speChars =~ s/(?:^\s|\s$)//g; $speChars =~ s/(?:^\s|\s$)//g;
$self->speChars($speChars); $self->speChars($speChars);
@ -238,18 +241,17 @@ sub display {
PING => $self->conf->{portalPingInterval}, PING => $self->conf->{portalPingInterval},
REQUIRE_OLDPASSWORD => REQUIRE_OLDPASSWORD =>
$self->requireOldPwd->( $req, $req->userData ), $self->requireOldPwd->( $req, $req->userData ),
HIDE_OLDPASSWORD => 0, HIDE_OLDPASSWORD => 0,
DISPLAY_PPOLICY => $self->conf->{portalDisplayPasswordPolicy}, PPOLICY_NOPOLICY => !$self->isPP(),
PPOLICY_MINSIZE => $self->conf->{passwordPolicyMinSize}, DISPLAY_PPOLICY => $self->conf->{portalDisplayPasswordPolicy},
PPOLICY_MINLOWER => $self->conf->{passwordPolicyMinLower}, PPOLICY_MINSIZE => $self->conf->{passwordPolicyMinSize},
PPOLICY_MINUPPER => $self->conf->{passwordPolicyMinUpper}, PPOLICY_MINLOWER => $self->conf->{passwordPolicyMinLower},
PPOLICY_MINDIGIT => $self->conf->{passwordPolicyMinDigit}, PPOLICY_MINUPPER => $self->conf->{passwordPolicyMinUpper},
PPOLICY_NOPOLICY => !$self->isPP(), PPOLICY_MINDIGIT => $self->conf->{passwordPolicyMinDigit},
PPOLICY_ALLOWEDSPECHAR => $self->speChars(), PPOLICY_MINSPECHAR => $self->conf->{passwordPolicyMinSpeChar},
( (
$self->speChars() $self->conf->{passwordPolicyMinSpeChar}
? ( PPOLICY_MINSPECHAR => ? ( PPOLICY_ALLOWEDSPECHAR => $self->speChars() )
$self->conf->{passwordPolicyMinSpeChar} )
: () : ()
), ),
$self->menu->params($req), $self->menu->params($req),
@ -406,17 +408,16 @@ sub display {
$req->data->{oldpassword} ) ? "" $req->data->{oldpassword} ) ? ""
: $req->data->{oldpassword}, : $req->data->{oldpassword},
HIDE_OLDPASSWORD => $self->conf->{hideOldPassword}, HIDE_OLDPASSWORD => $self->conf->{hideOldPassword},
PPOLICY_NOPOLICY => !$self->isPP(),
DISPLAY_PPOLICY => $self->conf->{portalDisplayPasswordPolicy}, DISPLAY_PPOLICY => $self->conf->{portalDisplayPasswordPolicy},
PPOLICY_MINSIZE => $self->conf->{passwordPolicyMinSize}, PPOLICY_MINSIZE => $self->conf->{passwordPolicyMinSize},
PPOLICY_MINLOWER => $self->conf->{passwordPolicyMinLower}, PPOLICY_MINLOWER => $self->conf->{passwordPolicyMinLower},
PPOLICY_MINUPPER => $self->conf->{passwordPolicyMinUpper}, PPOLICY_MINUPPER => $self->conf->{passwordPolicyMinUpper},
PPOLICY_MINDIGIT => $self->conf->{passwordPolicyMinDigit}, PPOLICY_MINDIGIT => $self->conf->{passwordPolicyMinDigit},
PPOLICY_NOPOLICY => !$self->isPP(), PPOLICY_MINSPECHAR => $self->conf->{passwordPolicyMinSpeChar},
PPOLICY_ALLOWEDSPECHAR => $self->speChars(),
( (
$self->speChars() $self->conf->{passwordPolicyMinSpeChar}
? ( PPOLICY_MINSPECHAR => ? ( PPOLICY_ALLOWEDSPECHAR => $self->speChars() )
$self->conf->{passwordPolicyMinSpeChar} )
: () : ()
), ),
); );

View File

@ -459,6 +459,21 @@ $(window).on 'load', () ->
$('#ppolicy-minspechar-feedback').removeClass 'fa-check text-success' $('#ppolicy-minspechar-feedback').removeClass 'fa-check text-success'
$('#ppolicy-minspechar-feedback').addClass 'fa-times text-danger' $('#ppolicy-minspechar-feedback').addClass 'fa-times text-danger'
result = false result = false
if window.datas.ppolicy.minspechar > 0 and !window.datas.ppolicy.allowedspechar
numspechar = 0
i = 0
while i < password.length
numspechar++ if !isAlphaNumeric(password.charAt(i))
i++
if numspechar >= window.datas.ppolicy.minspechar
$('#ppolicy-minspechar-feedback').addClass 'fa-check text-success'
$('#ppolicy-minspechar-feedback').removeClass 'fa-times text-danger'
else
$('#ppolicy-minspechar-feedback').removeClass 'fa-check text-success'
$('#ppolicy-minspechar-feedback').addClass 'fa-times text-danger'
result = false
if result if result
$('.ppolicy').removeClass('border-danger').addClass 'border-success' $('.ppolicy').removeClass('border-danger').addClass 'border-success'
$('#newpassword')[0].setCustomValidity('') $('#newpassword')[0].setCustomValidity('')

View File

@ -494,6 +494,24 @@ LemonLDAP::NG Portal jQuery scripts
result = false; result = false;
} }
} }
if (window.datas.ppolicy.minspechar > 0 && !window.datas.ppolicy.allowedspechar) {
numspechar = 0;
i = 0;
while (i < password.length) {
if (!isAlphaNumeric(password.charAt(i))) {
numspechar++;
}
i++;
}
if (numspechar >= window.datas.ppolicy.minspechar) {
$('#ppolicy-minspechar-feedback').addClass('fa-check text-success');
$('#ppolicy-minspechar-feedback').removeClass('fa-times text-danger');
} else {
$('#ppolicy-minspechar-feedback').removeClass('fa-check text-success');
$('#ppolicy-minspechar-feedback').addClass('fa-times text-danger');
result = false;
}
}
if (result) { if (result) {
$('.ppolicy').removeClass('border-danger').addClass('border-success'); $('.ppolicy').removeClass('border-danger').addClass('border-success');
$('#newpassword')[0].setCustomValidity(''); $('#newpassword')[0].setCustomValidity('');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long