From bded25d262d59742bccbe2ec7fd8fe416f564a90 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 ---------------- .../mysql/atomicupdate/bug_28772_api_keys.pl | 34 ------------------- installer/data/mysql/updatedatabase.pl | 30 ++++++++++++++++ 4 files changed, 31 insertions(+), 64 deletions(-) delete mode 100755 installer/data/mysql/atomicupdate/bug_28772_api_keys.perl delete mode 100755 installer/data/mysql/atomicupdate/bug_28772_api_keys.pl diff --git a/Koha.pm b/Koha.pm index 5971112670..7dd34d79a6 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 = "21.05.03.001"; +$VERSION = "21.05.03.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/atomicupdate/bug_28772_api_keys.pl b/installer/data/mysql/atomicupdate/bug_28772_api_keys.pl deleted file mode 100755 index 2baf5bf788..0000000000 --- a/installer/data/mysql/atomicupdate/bug_28772_api_keys.pl +++ /dev/null @@ -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} ); - } - } - }, -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 0279ae1143..3b1b9f297d 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -24436,6 +24436,36 @@ if( CheckVersion( $DBversion ) ) { 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 # if there is anything in the atomicupdate, read and execute it. my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/';