From 705f4ab2d32dcbaf93478f28eafba3536c273088 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Fri, 20 Oct 2017 22:32:46 +0000 Subject: [PATCH] Bug 18308 - Added step to onboarding tool to set minPasswordLength This patch increases the default minPasswordLength syspref value to 8 characters, for new installations. The final (6th step) of the onboarding tool is now a password length page where the default value of 8 can be altered. There is a security warning in red recommending to the user they keep the minimum length of the password at 8 characters or more. This patch also removes the atomicupdate .sql file to be run in an update to alter the default minPasswordLength value for existing Koha installations, based on tester feedback. Test plan: 1. Create a patron with a password less than 3 characters in length and notice that a red message is displayed by the input telling you that the password must be 3 characters minimum length 2. Query the database "select value from systempreferences where variable="minPasswordLength"; and notice the value is 3 3. Drop and recreate your database and restart memcached 4. Go through the web installer and onboarding tool. Noticing the last step of the onboarding tool is to create a circulation rule 5. Apply patch 6. Repeat step 3 7. Go through the web installer and onboarding tool. Noticing the last step of the onboarding tool is to set the minimum password length, the numerical input element has a default value of 8 and notice that it will go below 3 8. Repeat step 2 and notice the value is 8 9. In the onboarding tool change the minimum password length value to 7 and submit the form 10. Notice the completed page of the onboarding tool is displayed with the message that the minimum password length has been set. 11. Repeat step 2 and notice the value is now 7. 12. Try to create a patron in Intranet and OPAC with a password less than 7 characters and notice that a red message is displayed by the input telling you that the password must be 7 characters minimum length Sponsored-By: Catalyst IT Sponsored-By: Catalyst IT --- installer/data/mysql/sysprefs.sql | 2 +- installer/onboarding.pl | 22 ++++++++++++++++++++-- koha-tmpl/intranet-tmpl/prog/css/installer.css | 4 ++++ .../prog/en/includes/onboarding_messages.inc | 4 ++++ .../prog/en/modules/onboarding/onboardingstep5.tt | 10 ---------- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index e54e2ae..dd21ab8 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -272,7 +272,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('MaxSearchResultsItemsPerRecordStatusCheck','20','','Max number of items per record for which to check transit and hold status','Integer'), ('MembershipExpiryDaysNotice','',NULL,'Send an account expiration notice that a patron\'s card is about to expire after','Integer'), ('MergeReportFields','',NULL,'Displayed fields for deleted MARC records after merge','Free'), -('minPasswordLength','3',NULL,'Specify the minimum length of a patron/staff password','free'), +('minPasswordLength','8',NULL,'Specify the minimum length of a patron/staff password','free'), ('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''), ('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'), ('noissuescharge','5','','Define maximum amount withstanding before check outs are blocked','Integer'), diff --git a/installer/onboarding.pl b/installer/onboarding.pl index 76cc708..3d23514 100755 --- a/installer/onboarding.pl +++ b/installer/onboarding.pl @@ -272,6 +272,21 @@ if ( $step == 5 ) { $step++ if Koha::IssuingRules->count; } +if ( $step == 6 ) { + if ( $op eq 'set_validate_min_password_length' ) { + my $minPasswordLength = $input->param('pref_minPasswordLength'); + warn $minPasswordLength; + C4::Context->set_preference( 'minPasswordLength', $minPasswordLength ); + unless ($@) { + push @messages, { code => 'success_on_update_minPasswordLength_syspref' }; + $step++; + } + else { + push @messages, { code => 'error_on_update_minPasswordLength_syspref' }; + } + } +} + my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); $template_params->{libraries} = $libraries; $template_params->{group_types} = [ @@ -291,9 +306,12 @@ $template_params->{group_types} = [ }, ]; -if ( $step > 5 ) { +my $minPasswordLength = C4::Context->preference('minPasswordLength'); +$template_params->{minPasswordLength} = $minPasswordLength; + +if ( $step > 6 ) { $template_params->{all_done} = 1; # If step 5 is complete, we are done! - $step = 5; + $step = 6; } #Getting the appropriate template to display to the user diff --git a/koha-tmpl/intranet-tmpl/prog/css/installer.css b/koha-tmpl/intranet-tmpl/prog/css/installer.css index 7d5d3d9..c5f80ef 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/installer.css +++ b/koha-tmpl/intranet-tmpl/prog/css/installer.css @@ -241,3 +241,7 @@ span.breadcrumbs { .deselectall.optional { display: none; } + +#passwordlengthhint { + color:red; +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/onboarding_messages.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/onboarding_messages.inc index fbe0d3a..c8ef7a2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/onboarding_messages.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/onboarding_messages.inc @@ -32,6 +32,10 @@
The patron has not been created the entered password was too weak, must contain at least one uppercase, and lower case letter and one number
[% CASE 'ERROR_password_has_whitespaces' %]
The patron has not been created the entered password contained whitespaces
+ [% CASE 'success_on_update_minPasswordLength_syspref' %] +
Minimum password length set!
+ [% CASE 'error_on_update_minPasswordLength_syspref' %] +
Minimum password length not set!
[% CASE %][% message %] [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt index dfae544..b51ad3a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/onboarding/onboardingstep5.tt @@ -18,15 +18,6 @@

Koha

- [% IF all_done %] - -

Web installer › Complete

- [% INCLUDE 'onboarding_messages.inc' %] -

Congratulations you have finished and are ready to use Koha

- Start using Koha - - [% ELSE %] -

Web installer › Create a new circulation rule

[% INCLUDE 'onboarding_messages.inc' %] @@ -131,7 +122,6 @@ - [% END %]
-- 2.1.4