Bug 28772: Update existing keys
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
26a1b38573
commit
ad9bc3e8c7
1 changed files with 32 additions and 0 deletions
32
installer/data/mysql/atomicupdate/bug_28772_api_keys.pl
Executable file
32
installer/data/mysql/atomicupdate/bug_28772_api_keys.pl
Executable file
|
@ -0,0 +1,32 @@
|
|||
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) {
|
||||
my $digest = Koha::AuthUtils::hash_password( $api_key->{secret} );
|
||||
$sth->execute( $digest, $api_key->{client_id} );
|
||||
}
|
||||
},
|
||||
}
|
Loading…
Reference in a new issue