Bugzilla – Attachment 96560 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: Have AuthenticatePatron method send more information
Bug-23011-Have-AuthenticatePatron-method-send-more.patch (text/plain), 2.14 KB, created by
Arthur Suzuki
on 2019-12-22 05:21:07 UTC
(
hide
)
Description:
Bug 23011: Have AuthenticatePatron method send more information
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2019-12-22 05:21:07 UTC
Size:
2.14 KB
patch
obsolete
>From b754028f3c3215f16f1e16481e9ad1dfad6412f1 Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Fri, 20 Dec 2019 18:00:28 +0100 >Subject: [PATCH] Bug 23011: Have AuthenticatePatron method send more > information > >We want AuthenticatePatron to send some more information upon >successful login, especially in the case where password is not safe >and should be renewed. >The goal is to let a third-party app catch thoses codes and >display a warning to the users. > >Test plan : >1 / apply tests patch >2 / run tests, verify failure >3 / apply C4/ILSDI/Service.pm patch >4 / run tests again, verify green >--- > C4/ILSDI/Services.pm | 24 +++++++++++++++++------- > 1 file changed, 17 insertions(+), 7 deletions(-) > >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index 64caa4a6fa..eac9517b05 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -369,14 +369,24 @@ sub AuthenticatePatron { > my $username = $cgi->param('username'); > my $password = $cgi->param('password'); > my ($status, $cardnumber, $userid) = C4::Auth::checkpw( C4::Context->dbh, $username, $password ); >- if ( $status ) { >- # Get the borrower >- my $patron = Koha::Patrons->find( { userid => $userid } ); >- return { id => $patron->borrowernumber }; >- } >- else { >- return { code => 'PatronNotFound' }; >+ >+ return { code => 'PatronNotFound' } unless( $status ); >+ >+ # Get the borrower >+ my $patron = Koha::Patrons->find( { userid => $userid } ); >+ my $response->{id} = $patron->borrowernumber; >+ # Check passwd complexity against rules >+ my ($is_valid, $error) = Koha::AuthUtils::is_password_valid( $password ); >+ >+ 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'); > } >+ >+ return $response; > } > > =head2 GetPatronInfo >-- >2.20.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 23011
:
93512
|
93517
|
96560
|
96561
|
96562
|
100423
|
100424
|
100425
|
100426
|
106565
|
106566
|
106567