From fb64f96f6f44a3fe08986d7a6fcfad600a6641ee Mon Sep 17 00:00:00 2001 From: Victor Grousset/tuxayo Date: Mon, 20 Sep 2021 08:44:59 +0200 Subject: [PATCH] Bug 28772: DBRev 20.11.09.002 --- Koha.pm | 2 +- .../atomicupdate/bug_28772_api_keys.perl | 29 ------------------ installer/data/mysql/updatedatabase.pl | 30 +++++++++++++++++++ 3 files changed, 31 insertions(+), 30 deletions(-) delete mode 100755 installer/data/mysql/atomicupdate/bug_28772_api_keys.perl diff --git a/Koha.pm b/Koha.pm index 8d437acce8..fe6cf1dc2b 100644 --- a/Koha.pm +++ b/Koha.pm @@ -29,7 +29,7 @@ use vars qw{ $VERSION }; # - #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 # and is automatically called by Auth.pm when needed. -$VERSION = "20.11.09.001"; +$VERSION = "20.11.09.002"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug_28772_api_keys.perl b/installer/data/mysql/atomicupdate/bug_28772_api_keys.perl deleted file mode 100755 index 6265944586..0000000000 --- a/installer/data/mysql/atomicupdate/bug_28772_api_keys.perl +++ /dev/null @@ -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" ); -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 8781fa3366..77e62d3d1b 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -23657,6 +23657,36 @@ if( CheckVersion( $DBversion ) ) { NewVersion( $DBversion, "28774", "Delete blank rental discounts" ); } +$DBversion = '20.11.09.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 # if there is anything in the atomicupdate, read and execute it. my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/'; -- 2.20.1