From ac6ec91b136e4a1f0cfa7efbb738c594270ec6b2 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 30 Aug 2021 11:08:30 -0300 Subject: [PATCH] Bug 28772: Update existing keys [STABLE] Content-Type: text/plain; charset=utf-8 Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize Signed-off-by: Marcel de Rooy --- .../atomicupdate/bug_28772_api_keys.perl | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_28772_api_keys.perl diff --git a/installer/data/mysql/atomicupdate/bug_28772_api_keys.perl b/installer/data/mysql/atomicupdate/bug_28772_api_keys.perl new file mode 100755 index 0000000000..cb4529a71a --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_28772_api_keys.perl @@ -0,0 +1,27 @@ +$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) { + my $digest = Koha::AuthUtils::hash_password( $api_key->{secret} ); + $sth->execute( $digest, $api_key->{client_id} ); + } + + NewVersion( $DBversion, 28772, "Store hashed API key secrets" ); +} -- 2.20.1