View | Details | Raw Unified | Return to bug 29132
Collapse All | Expand All

(-)a/Koha.pm (-1 / +1 lines)
Lines 29-35 use vars qw{ $VERSION }; Link Here
29
# - #4 : the developer version. The 4th number is the database subversion.
29
# - #4 : the developer version. The 4th number is the database subversion.
30
#        used by developers when the database changes. updatedatabase take care of the changes itself
30
#        used by developers when the database changes. updatedatabase take care of the changes itself
31
#        and is automatically called by Auth.pm when needed.
31
#        and is automatically called by Auth.pm when needed.
32
$VERSION = "19.11.23.000";
32
$VERSION = "19.11.23.001";
33
33
34
sub version {
34
sub version {
35
    return $VERSION;
35
    return $VERSION;
(-)a/installer/data/mysql/atomicupdate/bug_28772_api_keys.pl (-32 lines)
Lines 1-32 Link Here
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
}
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +31 lines)
Lines 20843-20848 if ( CheckVersion($DBversion) ) { Link Here
20843
    SetVersion ($DBversion);
20843
    SetVersion ($DBversion);
20844
}
20844
}
20845
20845
20846
$DBversion = "19.11.23.001";
20847
if ( CheckVersion($DBversion) ) {
20848
20849
    require Koha::AuthUtils;
20850
20851
    my $sth = $dbh->prepare(q{
20852
        SELECT client_id, secret
20853
        FROM api_keys
20854
    });
20855
    $sth->execute;
20856
    my $results = $sth->fetchall_arrayref({});
20857
20858
    $sth = $dbh->prepare(q{
20859
        UPDATE api_keys
20860
        SET
20861
            secret = ?
20862
        WHERE
20863
            client_id = ?
20864
    });
20865
20866
    foreach my $api_key (@$results) {
20867
        unless ( $api_key->{secret} =~ m/^\$2a\$08\$/ ) {
20868
            my $digest = Koha::AuthUtils::hash_password( $api_key->{secret} );
20869
            $sth->execute( $digest, $api_key->{client_id} );
20870
        }
20871
    }
20872
20873
    print "Upgrade to $DBversion done (Bug 28772 - Store hashed API key secrets)\n";
20874
    SetVersion ($DBversion);
20875
}
20876
20846
# SEE bug 13068
20877
# SEE bug 13068
20847
# if there is anything in the atomicupdate, read and execute it.
20878
# if there is anything in the atomicupdate, read and execute it.
20848
my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/';
20879
my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/';
20849
- 

Return to bug 29132