diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-08-14 18:07:51 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-08-22 14:43:18 +0200 |
commit | aa383a8ff62fecd1a37d7b778ace37704f603e46 (patch) | |
tree | 22d0cd660ae4d9dcea60ca8d0f53ea8e3ca13cc3 | |
parent | 73e8ccbf72a6923b8e487a907c8aaa831b613ef3 (diff) | |
download | nextcloud-server-aa383a8ff62fecd1a37d7b778ace37704f603e46.tar.gz nextcloud-server-aa383a8ff62fecd1a37d7b778ace37704f603e46.zip |
fix(webauthn): Increase database column for public key id
* Resolves https://github.com/nextcloud/server/issues/34476
There is no maximum length defined in the standard,
most common the length is between 128 and 200 characters,
but as we store it not in plain data but base64 encoded the length can grow about 1/3.
We had a regression with 'Nitrokey 3' which created IDs with 196 byte length -> 262 bytes encoded base64.
So to be save we increase the size to 512 bytes.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r-- | core/Migrations/Version19000Date20200211083441.php | 2 | ||||
-rw-r--r-- | core/Migrations/Version30000Date20240814180800.php | 39 | ||||
-rw-r--r-- | lib/composer/composer/autoload_classmap.php | 1 | ||||
-rw-r--r-- | lib/composer/composer/autoload_static.php | 1 |
4 files changed, 42 insertions, 1 deletions
diff --git a/core/Migrations/Version19000Date20200211083441.php b/core/Migrations/Version19000Date20200211083441.php index 4b361149b30..2f8b46ad772 100644 --- a/core/Migrations/Version19000Date20200211083441.php +++ b/core/Migrations/Version19000Date20200211083441.php @@ -35,7 +35,7 @@ class Version19000Date20200211083441 extends SimpleMigrationStep { ]); $table->addColumn('public_key_credential_id', 'string', [ 'notnull' => true, - 'length' => 255 + 'length' => 512 ]); $table->addColumn('data', 'text', [ 'notnull' => true, diff --git a/core/Migrations/Version30000Date20240814180800.php b/core/Migrations/Version30000Date20240814180800.php new file mode 100644 index 00000000000..0f8d1ebc0ef --- /dev/null +++ b/core/Migrations/Version30000Date20240814180800.php @@ -0,0 +1,39 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OC\Core\Migrations; + +use Closure; +use OCP\DB\ISchemaWrapper; +use OCP\Migration\Attributes\ModifyColumn; +use OCP\Migration\IOutput; +use OCP\Migration\SimpleMigrationStep; + +#[ModifyColumn(table: 'webauthn', name: 'public_key_credential_id', description: 'Increase column length to 512 bytes to support more WebAuthN devices')] +class Version30000Date20240814180800 extends SimpleMigrationStep { + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { + /** @var ISchemaWrapper $schema */ + $schema = $schemaClosure(); + + $table = $schema->getTable('webauthn'); + $column = $table->getColumn('public_key_credential_id'); + + /** + * There is no maximum length defined in the standard, + * most common the length is between 128 and 200 characters, + * but as we store it not in plain data but base64 encoded the length can grow about 1/3. + * We had a regression with 'Nitrokey 3' which created IDs with 196 byte length -> 262 bytes encoded base64. + * So to be save we increase the size to 512 bytes. + */ + if ($column->getLength() < 512) { + $column->setLength(512); + } + + return $schema; + } +} diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index b58b51e8cbf..fca8883ae6c 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -1365,6 +1365,7 @@ return array( 'OC\\Core\\Migrations\\Version30000Date20240429122720' => $baseDir . '/core/Migrations/Version30000Date20240429122720.php', 'OC\\Core\\Migrations\\Version30000Date20240708160048' => $baseDir . '/core/Migrations/Version30000Date20240708160048.php', 'OC\\Core\\Migrations\\Version30000Date20240717111406' => $baseDir . '/core/Migrations/Version30000Date20240717111406.php', + 'OC\\Core\\Migrations\\Version30000Date20240814180800' => $baseDir . '/core/Migrations/Version30000Date20240814180800.php', 'OC\\Core\\Migrations\\Version30000Date20240815080800' => $baseDir . '/core/Migrations/Version30000Date20240815080800.php', 'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php', 'OC\\Core\\ResponseDefinitions' => $baseDir . '/core/ResponseDefinitions.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index c0e18224e9c..f780ee8ac31 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -1398,6 +1398,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Core\\Migrations\\Version30000Date20240429122720' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240429122720.php', 'OC\\Core\\Migrations\\Version30000Date20240708160048' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240708160048.php', 'OC\\Core\\Migrations\\Version30000Date20240717111406' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240717111406.php', + 'OC\\Core\\Migrations\\Version30000Date20240814180800' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240814180800.php', 'OC\\Core\\Migrations\\Version30000Date20240815080800' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240815080800.php', 'OC\\Core\\Notification\\CoreNotifier' => __DIR__ . '/../../..' . '/core/Notification/CoreNotifier.php', 'OC\\Core\\ResponseDefinitions' => __DIR__ . '/../../..' . '/core/ResponseDefinitions.php', |