Bugzilla – Attachment 93517 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]
Bug23011 : Have AuthenticatePatron method send more information
Bug23011--Have-AuthenticatePatron-method-send-more.patch (text/plain), 2.11 KB, created by
Arthur Suzuki
on 2019-10-03 07:24:52 UTC
(
hide
)
Description:
Bug23011 : Have AuthenticatePatron method send more information
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2019-10-03 07:24:52 UTC
Size:
2.11 KB
patch
obsolete
>From 24bb8117a9d3ba12d15f3c5eb816474459b2cc37 Mon Sep 17 00:00:00 2001 >From: Arthur Suzuki <arthur.suzuki@biblibre.com> >Date: Tue, 10 Sep 2019 02:08:17 +0200 >Subject: [PATCH] Bug23011 : 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 049ddcf600..f651830d1e 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