View | Details | Raw Unified | Return to bug 24151
Collapse All | Expand All

(-)a/Koha/PseudonymizedTransaction.pm (-4 / +4 lines)
Lines 103-120 sub new_from_statistic { Link Here
103
=head3 get_hash
103
=head3 get_hash
104
104
105
    Generates a hashed value for $s (e.g. borrowernumber) with Bcrypt.
105
    Generates a hashed value for $s (e.g. borrowernumber) with Bcrypt.
106
    Needs config entry 'key' in koha-conf.
106
    Needs config entry 'bcrypt_settings' in koha-conf.
107
107
108
=cut
108
=cut
109
109
110
sub get_hash {
110
sub get_hash {
111
    my ( $class, $s ) = @_;
111
    my ( $class, $s ) = @_;
112
    my $key = C4::Context->config('key');
112
    my $bcrypt_settings = C4::Context->config('bcrypt_settings');
113
113
114
    Koha::Exceptions::Config::MissingEntry->throw(
114
    Koha::Exceptions::Config::MissingEntry->throw(
115
        "Missing 'key' entry in config file") unless $key;
115
        "Missing 'bcrypt_settings' entry in config file") unless $bcrypt_settings;
116
116
117
    return bcrypt($s, $key);
117
    return bcrypt($s, $bcrypt_settings);
118
}
118
}
119
119
120
=head2 Internal methods
120
=head2 Internal methods
(-)a/about.pl (-3 / +3 lines)
Lines 519-528 $template->param( 'bad_yaml_prefs' => \@bad_yaml_prefs ) if @bad_yaml_prefs; Link Here
519
}
519
}
520
520
521
{
521
{
522
    # Test 'key' config for Pseudonymization
522
    # Test 'bcrypt_settings' config for Pseudonymization
523
    $template->param( config_key_no_set => 1 )
523
    $template->param( config_bcrypt_settings_no_set => 1 )
524
      if C4::Context->preference('Pseudonymization')
524
      if C4::Context->preference('Pseudonymization')
525
      and not C4::Context->config('key');
525
      and not C4::Context->config('bcrypt_settings');
526
}
526
}
527
527
528
my %versions = C4::Context::get_versions();
528
my %versions = C4::Context::get_versions();
(-)a/debian/scripts/koha-create (-2 / +2 lines)
Lines 111-117 generate_config_file() { Link Here
111
        -e "s/__UNIXGROUP__/$username/g" \
111
        -e "s/__UNIXGROUP__/$username/g" \
112
        -e "s#__TEMPLATE_CACHE_DIR__#$TEMPLATE_CACHE_DIR#g" \
112
        -e "s#__TEMPLATE_CACHE_DIR__#$TEMPLATE_CACHE_DIR#g" \
113
        -e "s#__TIMEZONE__#$TIMEZONE#g" \
113
        -e "s#__TIMEZONE__#$TIMEZONE#g" \
114
        -e "s#__KEY__#$KEY#g" \
114
        -e "s#__BCRYPT_SETTINGS__#$BCRYPT_SETTINGS#g" \
115
        -e "s#__UPLOAD_PATH__#$UPLOAD_PATH#g" \
115
        -e "s#__UPLOAD_PATH__#$UPLOAD_PATH#g" \
116
        -e "s#__TMP_PATH__#$TMP_PATH#g" \
116
        -e "s#__TMP_PATH__#$TMP_PATH#g" \
117
        -e "s/__LOG_DIR__/\/var\/log\/koha\/$name/g" \
117
        -e "s/__LOG_DIR__/\/var\/log\/koha\/$name/g" \
Lines 496-502 if [ "${CLO_ELASTICSEARCH_SERVER}" != "" ]; then Link Here
496
    ELASTICSEARCH_SERVER="${CLO_ELASTICSEARCH_SERVER}"
496
    ELASTICSEARCH_SERVER="${CLO_ELASTICSEARCH_SERVER}"
497
fi
497
fi
498
498
499
KEY=$(htpasswd -bnBC 10 "" password | tr -d ':\n' | sed 's/$2y/$2a/');
499
BCRYPT_SETTINGS=$(htpasswd -bnBC 10 "" password | tr -d ':\n' | sed 's/$2y/$2a/');
500
500
501
501
502
if [ "$ENABLE_SRU" != "no" ]; then
502
if [ "$ENABLE_SRU" != "no" ]; then
(-)a/debian/templates/koha-conf-site.xml.in (-2 / +2 lines)
Lines 403-410 __END_SRU_PUBLICSERVER__ Link Here
403
      server. e.g. Antarctica/South_Pole -->
403
      server. e.g. Antarctica/South_Pole -->
404
 <timezone>__TIMEZONE__</timezone>
404
 <timezone>__TIMEZONE__</timezone>
405
405
406
 <!-- This is the salt used to generated anonymized content -->
406
 <!-- This is the bcryt settings used to generated anonymized content -->
407
 <key>__KEY__</key>
407
 <key>__BCRYPT_SETTINGS__</key>
408
408
409
 <!-- flag for development purposes
409
 <!-- flag for development purposes
410
      dev_install is used to adjust some paths specific to dev installations
410
      dev_install is used to adjust some paths specific to dev installations
(-)a/etc/koha-conf.xml (-2 / +2 lines)
Lines 227-234 __PAZPAR2_TOGGLE_XML_POST__ Link Here
227
      server. e.g. Antarctica/South_Pole -->
227
      server. e.g. Antarctica/South_Pole -->
228
 <timezone></timezone>
228
 <timezone></timezone>
229
229
230
 <!-- This is the salt used to generated anonymized content -->
230
 <!-- This is the bcryt settings used to generated anonymized content -->
231
 <key>__KEY__</key>
231
 <key>__BCRYPT_SETTINGS__</key>
232
232
233
 <!-- flag for development purposes
233
 <!-- flag for development purposes
234
      dev_install is used to adjust some paths specific to dev installations
234
      dev_install is used to adjust some paths specific to dev installations
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt (-4 / +4 lines)
Lines 184-190 Link Here
184
        </div>
184
        </div>
185
185
186
        <div id="sysinfo">
186
        <div id="sysinfo">
187
    [% 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 %]
187
    [% 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 %]
188
        [% IF (warnIsRootUser) %]
188
        [% IF (warnIsRootUser) %]
189
            <h2>Warning regarding current user</h2>
189
            <h2>Warning regarding current user</h2>
190
            <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>
190
            <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>
Lines 259-265 Link Here
259
            [% END %]
259
            [% END %]
260
        [% END %]
260
        [% END %]
261
261
262
        [% 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 %]
262
        [% 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 %]
263
            <h2>Warnings regarding the system configuration</h2>
263
            <h2>Warnings regarding the system configuration</h2>
264
            <table>
264
            <table>
265
                <caption>Preferences and parameters</caption>
265
                <caption>Preferences and parameters</caption>
Lines 335-343 Link Here
335
                    Some system preferences have badly formatted YAML content: [% bad_yaml_prefs.join(', ') | html %]
335
                    Some system preferences have badly formatted YAML content: [% bad_yaml_prefs.join(', ') | html %]
336
                    </td></tr>
336
                    </td></tr>
337
                [% END %]
337
                [% END %]
338
                [% IF config_key_no_set %]
338
                [% IF config_bcrypt_settings_no_set %]
339
                    <tr><th scope="row"><b>Warning</b> </th><td>
339
                    <tr><th scope="row"><b>Warning</b> </th><td>
340
                    System preference 'Pseudonymization' is set, but there is not 'key' entry defined in the $KOHA_CONF file.
340
                    System preference 'Pseudonymization' is set, but there is not 'bcrypt_settings' entry defined in the $KOHA_CONF file.
341
                    </td></tr>
341
                    </td></tr>
342
                [% END %]
342
                [% END %]
343
            </table>
343
            </table>
(-)a/t/db_dependent/Koha/Pseudonymization.t (-6 / +5 lines)
Lines 42-48 subtest 'Config does not exist' => sub { Link Here
42
42
43
    $schema->storage->txn_begin;
43
    $schema->storage->txn_begin;
44
44
45
    t::lib::Mocks::mock_config( 'key', '' );
45
    t::lib::Mocks::mock_config( 'bcrypt_settings', '' );
46
    t::lib::Mocks::mock_preference( 'Pseudonymization', 1 );
46
    t::lib::Mocks::mock_preference( 'Pseudonymization', 1 );
47
    t::lib::Mocks::mock_preference( 'PseudonymizationPatronFields', 'branchcode,categorycode,sort1' );
47
    t::lib::Mocks::mock_preference( 'PseudonymizationPatronFields', 'branchcode,categorycode,sort1' );
48
48
Lines 64-71 subtest 'Config does not exist' => sub { Link Here
64
        );
64
        );
65
65
66
    } catch {
66
    } catch {
67
        ok($_->isa('Koha::Exceptions::Config::MissingEntry'), "Koha::Patron->store should raise a Koha::Exceptions::Config::MissingEntry if 'key' is not defined in the config");
67
        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");
68
        is( $_->message, "Missing 'key' entry in config file");
68
        is( $_->message, "Missing 'bcrypt_settings' entry in config file");
69
    };
69
    };
70
70
71
    $schema->storage->txn_rollback;
71
    $schema->storage->txn_rollback;
Lines 77-83 subtest 'Koha::Anonymized::Transactions tests' => sub { Link Here
77
77
78
    $schema->storage->txn_begin;
78
    $schema->storage->txn_begin;
79
79
80
    t::lib::Mocks::mock_config( 'key', '$2a$08$9lmorEKnwQloheaCLFIfje' );
80
    t::lib::Mocks::mock_config( 'bcrypt_settings', '$2a$08$9lmorEKnwQloheaCLFIfje' );
81
81
82
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
82
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
83
83
Lines 122-128 subtest 'PseudonymizedBorrowerAttributes tests' => sub { Link Here
122
122
123
    $schema->storage->txn_begin;
123
    $schema->storage->txn_begin;
124
124
125
    t::lib::Mocks::mock_config( 'key', '$2a$08$9lmorEKnwQloheaCLFIfje' );
125
    t::lib::Mocks::mock_config( 'bcrypt_settings', '$2a$08$9lmorEKnwQloheaCLFIfje' );
126
    t::lib::Mocks::mock_preference( 'Pseudonymization', 1 );
126
    t::lib::Mocks::mock_preference( 'Pseudonymization', 1 );
127
    t::lib::Mocks::mock_preference( 'PseudonymizationPatronFields',
127
    t::lib::Mocks::mock_preference( 'PseudonymizationPatronFields',
128
        'branchcode,categorycode,sort1' );
128
        'branchcode,categorycode,sort1' );
129
- 

Return to bug 24151