Bugzilla – Attachment 107383 Details for
Bug 12617
Koha should let admins to configure automatically generated password complexity/difficulty
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12617: Add new regex patterns to password_check.inc
0002-Bug-12617-Add-new-regex-patterns-to-password_check.i.patch (text/plain), 5.80 KB, created by
Emmi Takkinen
on 2020-07-27 07:23:52 UTC
(
hide
)
Description:
Bug 12617: Add new regex patterns to password_check.inc
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2020-07-27 07:23:52 UTC
Size:
5.80 KB
patch
obsolete
>From c2119efd3cc1c1fd4fa08a99aad20b86db3fe395 Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@outlook.com> >Date: Mon, 20 Jul 2020 10:48:01 +0300 >Subject: [PATCH 2/3] Bug 12617: Add new regex patterns to password_check.inc > >This patch adds new regex patterns to follow into password_check.inc >files. > >To test: >1. Create or find existing patron. >2. Set or edit invalid password for patron in OPAC and staff interfaces: > a) create and edit patron pages > b) 'Change password' pages >3. Confirm alert text next to input field is displayed and it follows >set passwordpolicy. > >Sponsored-by: Koha-Suomi Oy >--- > .../prog/en/includes/password_check.inc | 12 +++++++++++- > .../bootstrap/en/includes/password_check.inc | 12 +++++++++++- > members/memberentry.pl | 3 +++ > 3 files changed, 25 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/password_check.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/password_check.inc >index f057509dcc..d4ef9a6271 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/password_check.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/password_check.inc >@@ -5,12 +5,22 @@ > var pwd_title = ""; > var pattern_title = ""; > var new_password_node_name = "[% new_password | html %]"; >+ var password_policy = "[% password_policy | html %]"; > [% IF Koha.Preference('RequireStrongPassword') %] > pwd_title = _("Password must contain at least %s characters, including UPPERCASE, lowercase and numbers").format([% minPasswordLength | html %]); > pattern_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{[% minPasswordLength | html %],}/; >- [% ELSIF minPasswordLength %] >+ [% ELSIF minPasswordLength && !password_policy %] > pwd_title = _("Password must contain at least %s characters").format([% minPasswordLength | html %]); > pattern_regex = /.{[% minPasswordLength | html %],}/; >+ [% ELSIF password_policy == 'simplenumeric' %] >+ pwd_title = _("Password can only contain digits 0-9 and must be at least %s characters long").format([% minPasswordLength | html %]); >+ pattern_regex = /(?=.*\d)([0-9]){[% minPasswordLength | html %],}/; >+ [% ELSIF password_policy == 'alphanumeric' %] >+ pwd_title = _("Password must contain both numbers and non-special characters and must be at least %s characters long").format([% minPasswordLength | html %]); >+ pattern_regex = /(?=.*\d)(?=.*[a-zA-Z])([a-zA-Z0-9]){[% minPasswordLength | html %],}/; >+ [% ELSIF password_policy == 'complex' %] >+ pwd_title = _("Password must contain numbers, lower and uppercase characters and special characters and must be at least %s characters long").format([% minPasswordLength | html %]); >+ pattern_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\|\[\]\{\}!@#\$%\^&\*\(\)_\-\+\?])([a-zA-Z0-9\|\[\]\{\}!@#\$%\^&\*\(\)_\-\+\?]){[% minPasswordLength | html %],}/; > [% END %] > jQuery.validator.addMethod("password_strong", function(value, element){ > return this.optional(element) || value == '****' || pattern_regex.test(value); >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/password_check.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/password_check.inc >index 1a94309ae8..04df1e0724 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/password_check.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/password_check.inc >@@ -4,12 +4,22 @@ > var pwd_title = ""; > var pattern_title = ""; > var new_password_node_name = "[% new_password | html %]"; >+ var password_policy = "[% password_policy | html %]"; > [% IF Koha.Preference('RequireStrongPassword') %] > pwd_title = _("Password must contain at least %s characters, including UPPERCASE, lowercase and numbers").format([% minPasswordLength | html %]); > pattern_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{[% minPasswordLength | html %],}/; >- [% ELSIF minPasswordLength %] >+ [% ELSIF minPasswordLength && !password_policy %] > pwd_title = _("Password must contain at least %s characters").format([% minPasswordLength | html %]); > pattern_regex = /.{[% minPasswordLength | html %],}/; >+ [% ELSIF password_policy == 'simplenumeric' %] >+ pwd_title = _("Password can only contain digits 0-9 and must be at least %s characters long").format([% minPasswordLength | html %]); >+ pattern_regex = /(?=.*\d)([0-9]){[% minPasswordLength | html %],}/; >+ [% ELSIF password_policy == 'alphanumeric' %] >+ pwd_title = _("Password must contain both numbers and non-special characters and must be at least %s characters long").format([% minPasswordLength | html %]); >+ pattern_regex = /(?=.*\d)(?=.*[a-zA-Z])([a-zA-Z0-9]){[% minPasswordLength | html %],}/; >+ [% ELSIF password_policy == 'complex' %] >+ pwd_title = _("Password must contain numbers, lower and uppercase characters and special characters and must be at least %s characters long").format([% minPasswordLength | html %]); >+ pattern_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\|\[\]\{\}!@#\$%\^&\*\(\)_\-\+\?])([a-zA-Z0-9\|\[\]\{\}!@#\$%\^&\*\(\)_\-\+\?]){[% minPasswordLength | html %],}/; > [% END %] > jQuery.validator.addMethod("password_strong", function(value, element){ > return this.optional(element) || pattern_regex.test(value); >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 17a6651c01..75bd5a60d8 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -184,6 +184,9 @@ unless ($category_type or !($categorycode)){ > } > $category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error ! > >+my $passwordpolicy = $patron->category->passwordpolicy; >+$template->param(password_policy => $passwordpolicy); >+ > my $minpasslength = Koha::AuthUtils::min_password_length($categorycode); > $template->param("minPasswordLength" => $minpasslength); > >-- >2.17.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12617
:
37740
|
107382
|
107383
|
107384
|
109388
|
109389
|
110526
|
110527
|
110528
|
111297
|
111298
|
111299