From 90b55780bbdc41dde35f1f45ee8dd19538d0d26d Mon Sep 17 00:00:00 2001 From: Paul Derscheid Date: Fri, 6 Mar 2026 11:23:54 +0100 Subject: [PATCH] Bug 39601: Atomic update --- .../bug_39601_add_passkey_support.pl | 53 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 25 +++++++++ 2 files changed, 78 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_39601_add_passkey_support.pl diff --git a/installer/data/mysql/atomicupdate/bug_39601_add_passkey_support.pl b/installer/data/mysql/atomicupdate/bug_39601_add_passkey_support.pl new file mode 100755 index 00000000000..5d6c7ad0f15 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_39601_add_passkey_support.pl @@ -0,0 +1,53 @@ +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "39601", + description => "Add passkey support to Koha as an authentication mechanism", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Create webauthn_credentials table + if ( !TableExists('webauthn_credentials') ) { + $dbh->do( + q{ + CREATE TABLE `webauthn_credentials` ( + `webauthn_credential_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key', + `borrowernumber` int(11) NOT NULL COMMENT 'foreign key to borrowers.borrowernumber', + `credential_id` varbinary(1024) NOT NULL COMMENT 'WebAuthn credential identifier', + `public_key` varbinary(1024) NOT NULL COMMENT 'COSE public key for the credential', + `sign_count` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'signature counter for replay detection', + `transports` varchar(255) DEFAULT NULL COMMENT 'comma-separated list of authenticator transports', + `nickname` varchar(255) DEFAULT NULL COMMENT 'user-assigned name for the credential', + `created_date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date and time the credential was registered', + `last_used_date` datetime DEFAULT NULL COMMENT 'date and time the credential was last used to authenticate', + PRIMARY KEY (`webauthn_credential_id`), + UNIQUE KEY `credential_id` (`credential_id`), + KEY `fk_webauthn_credentials_borrowernumber` (`borrowernumber`), + CONSTRAINT `fk_webauthn_credentials_borrowernumber` FOREIGN KEY (`borrowernumber`) + REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + } + ); + say_success( $out, "Created table 'webauthn_credentials'" ); + } else { + say_info( $out, "Table 'webauthn_credentials' already exists!" ); + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index e73c258a99c..cbf1f89f374 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -7063,6 +7063,31 @@ CREATE TABLE `virtualshelves` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `webauthn_credentials` +-- + +DROP TABLE IF EXISTS `webauthn_credentials`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `webauthn_credentials` ( + `webauthn_credential_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key', + `borrowernumber` int(11) NOT NULL COMMENT 'foreign key to borrowers.borrowernumber', + `credential_id` varbinary(1024) NOT NULL COMMENT 'WebAuthn credential identifier', + `public_key` varbinary(1024) NOT NULL COMMENT 'COSE public key for the credential', + `sign_count` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'signature counter for replay detection', + `transports` varchar(255) DEFAULT NULL COMMENT 'comma-separated list of authenticator transports', + `nickname` varchar(255) DEFAULT NULL COMMENT 'user-assigned name for the credential', + `created_date` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'date and time the credential was registered', + `last_used_date` datetime DEFAULT NULL COMMENT 'date and time the credential was last used to authenticate', + PRIMARY KEY (`webauthn_credential_id`), + UNIQUE KEY `credential_id` (`credential_id`), + KEY `fk_webauthn_credentials_borrowernumber` (`borrowernumber`), + CONSTRAINT `fk_webauthn_credentials_borrowernumber` FOREIGN KEY (`borrowernumber`) + REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `z3950servers` -- -- 2.39.5