Bug 28772: DBRev 20.11.09.002

This commit is contained in:
Victor Grousset 2021-09-20 08:44:59 +02:00 committed by Kyle M Hall
parent 73e806f902
commit bded25d262
4 changed files with 31 additions and 64 deletions

View file

@ -29,7 +29,7 @@ use vars qw{ $VERSION };
# - #4 : the developer version. The 4th number is the database subversion. # - #4 : the developer version. The 4th number is the database subversion.
# used by developers when the database changes. updatedatabase take care of the changes itself # used by developers when the database changes. updatedatabase take care of the changes itself
# and is automatically called by Auth.pm when needed. # and is automatically called by Auth.pm when needed.
$VERSION = "21.05.03.001"; $VERSION = "21.05.03.002";
sub version { sub version {
return $VERSION; return $VERSION;

View file

@ -1,29 +0,0 @@
$DBversion = 'XXX';
if( CheckVersion( $DBversion ) ) {
use Koha::AuthUtils qw(hash_password);
my $sth = $dbh->prepare(q{
SELECT client_id, secret
FROM api_keys
});
$sth->execute;
my $results = $sth->fetchall_arrayref({});
$sth = $dbh->prepare(q{
UPDATE api_keys
SET
secret = ?
WHERE
client_id = ?
});
foreach my $api_key (@$results) {
unless ( $api_key->{secret} =~ m/^\$2a\$08\$/ ) {
my $digest = Koha::AuthUtils::hash_password( $api_key->{secret} );
$sth->execute( $digest, $api_key->{client_id} );
}
}
NewVersion( $DBversion, 28772, "Store hashed API key secrets" );
}

View file

@ -1,34 +0,0 @@
use Modern::Perl;
return {
bug_number => "28772",
description => "Store hashed API key secrets",
up => sub {
my ($args) = @_;
my ($dbh) = @$args{qw(dbh)};
use Koha::AuthUtils qw(hash_password);
my $sth = $dbh->prepare(q{
SELECT client_id, secret
FROM api_keys
});
$sth->execute;
my $results = $sth->fetchall_arrayref({});
$sth = $dbh->prepare(q{
UPDATE api_keys
SET
secret = ?
WHERE
client_id = ?
});
foreach my $api_key (@$results) {
unless ( $api_key->{secret} =~ m/^\$2a\$08\$/ ) {
my $digest = Koha::AuthUtils::hash_password( $api_key->{secret} );
$sth->execute( $digest, $api_key->{client_id} );
}
}
},
}

View file

@ -24436,6 +24436,36 @@ if( CheckVersion( $DBversion ) ) {
NewVersion( $DBversion, "28774", "Delete blank rental discounts" ); NewVersion( $DBversion, "28774", "Delete blank rental discounts" );
} }
$DBversion = '21.05.03.002';
if ( CheckVersion( $DBversion ) ) {
use Koha::AuthUtils qw(hash_password);
my $sth = $dbh->prepare(q{
SELECT client_id, secret
FROM api_keys
});
$sth->execute;
my $results = $sth->fetchall_arrayref({});
$sth = $dbh->prepare(q{
UPDATE api_keys
SET
secret = ?
WHERE
client_id = ?
});
foreach my $api_key (@$results) {
unless ( $api_key->{secret} =~ m/^\$2a\$08\$/ ) {
my $digest = Koha::AuthUtils::hash_password( $api_key->{secret} );
$sth->execute( $digest, $api_key->{client_id} );
}
}
NewVersion( $DBversion, 28772, "Store hashed API key secrets" );
}
# SEE bug 13068 # SEE bug 13068
# if there is anything in the atomicupdate, read and execute it. # if there is anything in the atomicupdate, read and execute it.
my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/'; my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/';