Bugzilla – Attachment 106567 Details for
Bug 23011
AuthenticatePatron could alert if password is not safe
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23011: QA follow-up
Bug-23011-QA-follow-up.patch (text/plain), 2.99 KB, created by
Arthur Suzuki
on 2020-07-05 21:06:24 UTC
(
hide
)
Description:
Bug 23011: QA follow-up
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2020-07-05 21:06:24 UTC
Size:
2.99 KB
patch
obsolete
>From 66667cf54e29f4b9a0a72744b658a5cb6de79509 Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Sun, 5 Jul 2020 23:03:43 +0200 >Subject: [PATCH] Bug 23011: QA follow-up > >--- > C4/ILSDI/Services.pm | 5 ++--- > Koha/AuthUtils.pm | 17 +++++++++++++++++ > t/db_dependent/ILSDI_Services.t | 6 +++++- > 3 files changed, 24 insertions(+), 4 deletions(-) > >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index 42c036cc3c..e97a2f516d 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -380,9 +380,8 @@ sub AuthenticatePatron { > unless( $is_valid ) { > $response->{code} = 'PatronPasswordNotSecure'; > $response->{securePasswordLabel} = $error; >- my $minPasswordLength = C4::Context->preference('minPasswordLength'); >- $response->{securePasswordPattern} = '.{'.$minPasswordLength.'}' if( $error eq 'too_short'); >- $response->{securePasswordPattern} = '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{'.$minPasswordLength.'}' if( $error eq 'too_weak'); >+ my $minPasswordLength = C4::Context->preference('minPasswordLength') // 3; >+ $response->{securePasswordPattern} = Koha::AuthUtils::password_policy(); > } > > return $response; >diff --git a/Koha/AuthUtils.pm b/Koha/AuthUtils.pm >index 7c4dcd1002..e41e570053 100644 >--- a/Koha/AuthUtils.pm >+++ b/Koha/AuthUtils.pm >@@ -161,6 +161,23 @@ sub is_password_valid { > return ( 1, undef ); > } > >+=head2 password_policy >+ >+my ( $regex) = password_policy(); >+ >+return a regex matching the password policy in use >+ >+=cut >+ >+sub password_policy { >+ my $minPasswordLength = C4::Context->preference('minPasswordLength'); >+ $minPasswordLength = 3 if not $minPasswordLength or $minPasswordLength < 3; >+ if ( C4::Context->preference('RequireStrongPassword') ) { >+ return '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{'.$minPasswordLength.'}'; >+ } >+ return '.{'.$minPasswordLength.'}'; >+} >+ > =head2 generate_password > > my password = generate_password(); >diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t >index 4519a673d5..8d18a80414 100644 >--- a/t/db_dependent/ILSDI_Services.t >+++ b/t/db_dependent/ILSDI_Services.t >@@ -19,7 +19,7 @@ use Modern::Perl; > > use CGI qw ( -utf8 ); > >-use Test::More tests => 10; >+use Test::More tests => 11; > use Test::MockModule; > use t::lib::Mocks; > use t::lib::TestBuilder; >@@ -44,6 +44,8 @@ subtest 'AuthenticatePatron test' => sub { > $schema->storage->txn_begin; > > my $plain_password = 'tomasito'; >+ t::lib::Mocks::mock_preference( 'minPasswordLength', 0 ); >+ t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); > > $builder->build({ > source => 'Borrower', >@@ -111,6 +113,8 @@ subtest 'AuthenticatePatron Secure Password test' => sub { > $schema->storage->txn_begin; > > my $plain_password = 'tomasito'; >+ t::lib::Mocks::mock_preference( 'minPasswordLength', 0 ); >+ t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 ); > > $builder->build({ > source => 'Borrower', >-- >2.11.0
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 23011
:
93512
|
93517
|
96560
|
96561
|
96562
|
100423
|
100424
|
100425
|
100426
|
106565
|
106566
| 106567