From e504ad8bc1ed7f24db9638eca1b04d5e8d8aa6d5 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.05.15.001 Signed-off-by: Victor Grousset/tuxayo --- 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 d58a5a3977..aed188cef6 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.05.15.000"; +$VERSION = "20.05.15.001"; 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 826126d1d4..7e38c65735 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -22678,6 +22678,36 @@ if( CheckVersion( $DBversion ) ) { NewVersion( $DBversion, "", "Koha 20.05.15 release" ); } +$DBversion = '20.05.15.001'; +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.39.5