mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 09:09:01 +00:00
50 lines
2.7 KiB
PHP
50 lines
2.7 KiB
PHP
<?php
|
|
|
|
/*
|
|
* ITFlow - Database update to version 4.2.2 (from 4.2.1)
|
|
* Included by admin/database_updates.php - do not access directly
|
|
*
|
|
* Signing in with a passkey (functions/passkey.php), for agents and client portal contacts:
|
|
* user_passkeys - each passkey a user added: its name, the credential's id (and a hash of it, to
|
|
* find it by), its public key, the authenticator's signature count, whether it is synced
|
|
* between devices, and for an agent a copy of the vault key sealed by the passkey itself
|
|
* (passkey_vault, '' when the passkey can't open the vault)
|
|
* users.user_passkey_handle - the random id a user's passkeys are made for, the same for each
|
|
* settings.config_login_passkeys - whether passkeys can be used to sign in (on)
|
|
*
|
|
* Re-runnable: the table is made only when it isn't there, and each column only where it isn't.
|
|
*/
|
|
|
|
defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
|
|
|
|
mysqli_query($mysqli, "CREATE TABLE IF NOT EXISTS `user_passkeys` (
|
|
`passkey_id` int(11) NOT NULL AUTO_INCREMENT,
|
|
`passkey_user_id` int(11) NOT NULL,
|
|
`passkey_name` varchar(200) NOT NULL,
|
|
`passkey_credential_id` varchar(1400) NOT NULL,
|
|
`passkey_credential_hash` char(64) NOT NULL,
|
|
`passkey_public_key` text NOT NULL,
|
|
`passkey_sign_count` int(10) unsigned NOT NULL DEFAULT 0,
|
|
`passkey_aaguid` char(36) NOT NULL DEFAULT '',
|
|
`passkey_transports` varchar(100) NOT NULL DEFAULT '',
|
|
`passkey_synced` tinyint(1) NOT NULL DEFAULT 0,
|
|
`passkey_vault` varchar(255) NOT NULL DEFAULT '',
|
|
`passkey_created_at` datetime NOT NULL DEFAULT current_timestamp(),
|
|
`passkey_used_at` datetime DEFAULT NULL,
|
|
PRIMARY KEY (`passkey_id`),
|
|
UNIQUE KEY `passkey_credential_hash` (`passkey_credential_hash`),
|
|
KEY `passkey_user_id` (`passkey_user_id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci");
|
|
|
|
$itflow_passkey_columns = [
|
|
['users', 'user_passkey_handle', "varchar(64) DEFAULT NULL AFTER `user_token`"],
|
|
['settings', 'config_login_passkeys', "tinyint(1) NOT NULL DEFAULT 1 AFTER `config_login_remember_me_expire`"],
|
|
];
|
|
foreach ($itflow_passkey_columns as [$itflow_table, $itflow_column, $itflow_definition]) {
|
|
$itflow_column_exists = mysqli_query($mysqli, "SELECT 1 FROM information_schema.COLUMNS
|
|
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '$itflow_table' AND COLUMN_NAME = '$itflow_column' LIMIT 1");
|
|
if (!$itflow_column_exists || mysqli_num_rows($itflow_column_exists) === 0) {
|
|
mysqli_query($mysqli, "ALTER TABLE `$itflow_table` ADD `$itflow_column` $itflow_definition");
|
|
}
|
|
}
|