Bug 24151: Rename the config key with 'bcrypt_settings'
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 24 Jun 2020 14:45:12 +0000 (16:45 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 20 Jul 2020 13:17:42 +0000 (15:17 +0200)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Koha/PseudonymizedTransaction.pm
about.pl
debian/scripts/koha-create
debian/templates/koha-conf-site.xml.in
etc/koha-conf.xml
koha-tmpl/intranet-tmpl/prog/en/modules/about.tt
t/db_dependent/Koha/Pseudonymization.t

index 4af9116..78a1190 100644 (file)
@@ -103,18 +103,18 @@ sub new_from_statistic {
 =head3 get_hash
 
     Generates a hashed value for $s (e.g. borrowernumber) with Bcrypt.
-    Needs config entry 'key' in koha-conf.
+    Needs config entry 'bcrypt_settings' in koha-conf.
 
 =cut
 
 sub get_hash {
     my ( $class, $s ) = @_;
-    my $key = C4::Context->config('key');
+    my $bcrypt_settings = C4::Context->config('bcrypt_settings');
 
     Koha::Exceptions::Config::MissingEntry->throw(
-        "Missing 'key' entry in config file") unless $key;
+        "Missing 'bcrypt_settings' entry in config file") unless $bcrypt_settings;
 
-    return bcrypt($s, $key);
+    return bcrypt($s, $bcrypt_settings);
 }
 
 =head2 Internal methods
index 2135399..b44e531 100755 (executable)
--- a/about.pl
+++ b/about.pl
@@ -519,10 +519,10 @@ $template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs;
 }
 
 {
-    # Test 'key' config for Pseudonymization
-    $template->param( config_key_no_set => 1 )
+    # Test 'bcrypt_settings' config for Pseudonymization
+    $template->param( config_bcrypt_settings_no_set => 1 )
       if C4::Context->preference('Pseudonymization')
-      and not C4::Context->config('key');
+      and not C4::Context->config('bcrypt_settings');
 }
 
 my %versions = C4::Context::get_versions();
index 5cc3f2f..390879f 100755 (executable)
@@ -111,7 +111,7 @@ generate_config_file() {
         -e "s/__UNIXGROUP__/$username/g" \
         -e "s#__TEMPLATE_CACHE_DIR__#$TEMPLATE_CACHE_DIR#g" \
         -e "s#__TIMEZONE__#$TIMEZONE#g" \
-        -e "s#__KEY__#$KEY#g" \
+        -e "s#__BCRYPT_SETTINGS__#$BCRYPT_SETTINGS#g" \
         -e "s#__UPLOAD_PATH__#$UPLOAD_PATH#g" \
         -e "s#__TMP_PATH__#$TMP_PATH#g" \
         -e "s/__LOG_DIR__/\/var\/log\/koha\/$name/g" \
@@ -496,7 +496,7 @@ if [ "${CLO_ELASTICSEARCH_SERVER}" != "" ]; then
     ELASTICSEARCH_SERVER="${CLO_ELASTICSEARCH_SERVER}"
 fi
 
-KEY=$(htpasswd -bnBC 10 "" password | tr -d ':\n' | sed 's/$2y/$2a/');
+BCRYPT_SETTINGS=$(htpasswd -bnBC 10 "" password | tr -d ':\n' | sed 's/$2y/$2a/');
 
 
 if [ "$ENABLE_SRU" != "no" ]; then
index 099a65b..4853018 100644 (file)
@@ -403,8 +403,8 @@ __END_SRU_PUBLICSERVER__
       server. e.g. Antarctica/South_Pole -->
  <timezone>__TIMEZONE__</timezone>
 
- <!-- This is the salt used to generated anonymized content -->
- <key>__KEY__</key>
+ <!-- This is the bcryt settings used to generated anonymized content -->
+ <key>__BCRYPT_SETTINGS__</key>
 
  <!-- flag for development purposes
       dev_install is used to adjust some paths specific to dev installations
index f3697ed..2ffe624 100644 (file)
@@ -227,8 +227,8 @@ __PAZPAR2_TOGGLE_XML_POST__
       server. e.g. Antarctica/South_Pole -->
  <timezone></timezone>
 
- <!-- This is the salt used to generated anonymized content -->
- <key>__KEY__</key>
+ <!-- This is the bcryt settings used to generated anonymized content -->
+ <key>__BCRYPT_SETTINGS__</key>
 
  <!-- flag for development purposes
       dev_install is used to adjust some paths specific to dev installations
index d3dae64..70ed9b1 100644 (file)
         </div>
 
         <div id="sysinfo">
-    [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnNoActiveCurrency || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues || oauth2_missing_deps || bad_yaml_prefs || warnRelationships || log4perl_errors || config_key_no_set %]
+    [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnNoActiveCurrency || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues || oauth2_missing_deps || bad_yaml_prefs || warnRelationships || log4perl_errors || config_bcrypt_settings_no_set %]
         [% IF (warnIsRootUser) %]
             <h2>Warning regarding current user</h2>
             <p>You are logged in as the database administrative user. This is not recommended because some parts of Koha will not function as expected when using this account.</p>
             [% END %]
         [% END %]
 
-        [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnNoActiveCurrency || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps || bad_yaml_prefs || warnIssuingRules || config_key_no_set %]
+        [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnNoActiveCurrency || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps || bad_yaml_prefs || warnIssuingRules || config_bcrypt_settings_no_set %]
             <h2>Warnings regarding the system configuration</h2>
             <table>
                 <caption>Preferences and parameters</caption>
                     Some system preferences have badly formatted YAML content: [% bad_yaml_prefs.join(', ') | html %]
                     </td></tr>
                 [% END %]
-                [% IF config_key_no_set %]
+                [% IF config_bcrypt_settings_no_set %]
                     <tr><th scope="row"><b>Warning</b> </th><td>
-                    System preference 'Pseudonymization' is set, but there is not 'key' entry defined in the $KOHA_CONF file.
+                    System preference 'Pseudonymization' is set, but there is not 'bcrypt_settings' entry defined in the $KOHA_CONF file.
                     </td></tr>
                 [% END %]
             </table>
index b1d12ad..cfefc82 100644 (file)
@@ -42,7 +42,7 @@ subtest 'Config does not exist' => sub {
 
     $schema->storage->txn_begin;
 
-    t::lib::Mocks::mock_config( 'key', '' );
+    t::lib::Mocks::mock_config( 'bcrypt_settings', '' );
     t::lib::Mocks::mock_preference( 'Pseudonymization', 1 );
     t::lib::Mocks::mock_preference( 'PseudonymizationPatronFields', 'branchcode,categorycode,sort1' );
 
@@ -64,8 +64,8 @@ subtest 'Config does not exist' => sub {
         );
 
     } catch {
-        ok($_->isa('Koha::Exceptions::Config::MissingEntry'), "Koha::Patron->store should raise a Koha::Exceptions::Config::MissingEntry if 'key' is not defined in the config");
-        is( $_->message, "Missing 'key' entry in config file");
+        ok($_->isa('Koha::Exceptions::Config::MissingEntry'), "Koha::Patron->store should raise a Koha::Exceptions::Config::MissingEntry if 'bcrypt_settings' is not defined in the config");
+        is( $_->message, "Missing 'bcrypt_settings' entry in config file");
     };
 
     $schema->storage->txn_rollback;
@@ -77,7 +77,7 @@ subtest 'Koha::Anonymized::Transactions tests' => sub {
 
     $schema->storage->txn_begin;
 
-    t::lib::Mocks::mock_config( 'key', '$2a$08$9lmorEKnwQloheaCLFIfje' );
+    t::lib::Mocks::mock_config( 'bcrypt_settings', '$2a$08$9lmorEKnwQloheaCLFIfje' );
 
     my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
 
@@ -122,7 +122,7 @@ subtest 'PseudonymizedBorrowerAttributes tests' => sub {
 
     $schema->storage->txn_begin;
 
-    t::lib::Mocks::mock_config( 'key', '$2a$08$9lmorEKnwQloheaCLFIfje' );
+    t::lib::Mocks::mock_config( 'bcrypt_settings', '$2a$08$9lmorEKnwQloheaCLFIfje' );
     t::lib::Mocks::mock_preference( 'Pseudonymization', 1 );
     t::lib::Mocks::mock_preference( 'PseudonymizationPatronFields',
         'branchcode,categorycode,sort1' );