Bug 24151: Rename the config key with 'bcrypt_settings'

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2020-06-24 16:45:12 +02:00
parent 6998e54b5e
commit e2b6a2de23
7 changed files with 22 additions and 22 deletions

View 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

View File

@ -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();

View File

@ -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

View 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

View 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

View File

@ -184,7 +184,7 @@
</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>
@ -259,7 +259,7 @@
[% 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>
@ -335,9 +335,9 @@
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>

View 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' );