|
Line 0
Link Here
|
| 0 |
- |
1 |
use Modern::Perl; |
|
|
2 |
|
| 3 |
return { |
| 4 |
bug_number => "28772", |
| 5 |
description => "Store hashed API key secrets", |
| 6 |
up => sub { |
| 7 |
my ($args) = @_; |
| 8 |
my ($dbh) = @$args{qw(dbh)}; |
| 9 |
|
| 10 |
use Koha::AuthUtils qw(hash_password); |
| 11 |
|
| 12 |
my $sth = $dbh->prepare(q{ |
| 13 |
SELECT client_id, secret |
| 14 |
FROM api_keys |
| 15 |
}); |
| 16 |
$sth->execute; |
| 17 |
my $results = $sth->fetchall_arrayref({}); |
| 18 |
|
| 19 |
$sth = $dbh->prepare(q{ |
| 20 |
UPDATE api_keys |
| 21 |
SET |
| 22 |
secret = ? |
| 23 |
WHERE |
| 24 |
client_id = ? |
| 25 |
}); |
| 26 |
|
| 27 |
foreach my $api_key (@$results) { |
| 28 |
my $digest = Koha::AuthUtils::hash_password( $api_key->{secret} ); |
| 29 |
$sth->execute( $digest, $api_key->{client_id} ); |
| 30 |
} |
| 31 |
}, |
| 32 |
} |