|
Line 0
Link Here
|
|
|
1 |
# This file is part of Koha. |
| 2 |
# |
| 3 |
# Koha is free software; you can redistribute it and/or modify it |
| 4 |
# under the terms of the GNU General Public License as published by |
| 5 |
# the Free Software Foundation; either version 3 of the License, or |
| 6 |
# (at your option) any later version. |
| 7 |
# |
| 8 |
# Koha is distributed in the hope that it will be useful, but |
| 9 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
# GNU General Public License for more details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU General Public License |
| 14 |
# along with Koha; if not, see <https://www.gnu.org/licenses>. |
| 15 |
|
| 16 |
use Modern::Perl; |
| 17 |
use Koha::Installer::Output qw(say_warning say_success say_info); |
| 18 |
|
| 19 |
return { |
| 20 |
bug_number => "39601", |
| 21 |
description => "Add passkey support to Koha as an authentication mechanism", |
| 22 |
up => sub { |
| 23 |
my ($args) = @_; |
| 24 |
my ( $dbh, $out ) = @$args{qw(dbh out)}; |
| 25 |
|
| 26 |
# Create webauthn_credentials table |
| 27 |
if ( !TableExists('webauthn_credentials') ) { |
| 28 |
$dbh->do( |
| 29 |
q{ |
| 30 |
CREATE TABLE `webauthn_credentials` ( |
| 31 |
`webauthn_credential_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key', |
| 32 |
`borrowernumber` int(11) NOT NULL COMMENT 'foreign key to borrowers.borrowernumber', |
| 33 |
`credential_id` varbinary(1024) NOT NULL COMMENT 'WebAuthn credential identifier', |
| 34 |
`public_key` varbinary(1024) NOT NULL COMMENT 'COSE public key for the credential', |
| 35 |
`sign_count` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'signature counter for replay detection', |
| 36 |
`transports` varchar(255) DEFAULT NULL COMMENT 'comma-separated list of authenticator transports', |
| 37 |
`nickname` varchar(255) DEFAULT NULL COMMENT 'user-assigned name for the credential', |
| 38 |
`created_date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date and time the credential was registered', |
| 39 |
`last_used_date` datetime DEFAULT NULL COMMENT 'date and time the credential was last used to authenticate', |
| 40 |
PRIMARY KEY (`webauthn_credential_id`), |
| 41 |
UNIQUE KEY `credential_id` (`credential_id`), |
| 42 |
KEY `fk_webauthn_credentials_borrowernumber` (`borrowernumber`), |
| 43 |
CONSTRAINT `fk_webauthn_credentials_borrowernumber` FOREIGN KEY (`borrowernumber`) |
| 44 |
REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE |
| 45 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; |
| 46 |
} |
| 47 |
); |
| 48 |
say_success( $out, "Created table 'webauthn_credentials'" ); |
| 49 |
} else { |
| 50 |
say_info( $out, "Table 'webauthn_credentials' already exists!" ); |
| 51 |
} |
| 52 |
}, |
| 53 |
}; |