Skip to content

Commit aa383a8

Browse files
susnuxnickvergessen
authored andcommitted
fix(webauthn): Increase database column for public key id
* Resolves #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>
1 parent 73e8ccb commit aa383a8

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

core/Migrations/Version19000Date20200211083441.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
3535
]);
3636
$table->addColumn('public_key_credential_id', 'string', [
3737
'notnull' => true,
38-
'length' => 255
38+
'length' => 512
3939
]);
4040
$table->addColumn('data', 'text', [
4141
'notnull' => true,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
namespace OC\Core\Migrations;
10+
11+
use Closure;
12+
use OCP\DB\ISchemaWrapper;
13+
use OCP\Migration\Attributes\ModifyColumn;
14+
use OCP\Migration\IOutput;
15+
use OCP\Migration\SimpleMigrationStep;
16+
17+
#[ModifyColumn(table: 'webauthn', name: 'public_key_credential_id', description: 'Increase column length to 512 bytes to support more WebAuthN devices')]
18+
class Version30000Date20240814180800 extends SimpleMigrationStep {
19+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
20+
/** @var ISchemaWrapper $schema */
21+
$schema = $schemaClosure();
22+
23+
$table = $schema->getTable('webauthn');
24+
$column = $table->getColumn('public_key_credential_id');
25+
26+
/**
27+
* There is no maximum length defined in the standard,
28+
* most common the length is between 128 and 200 characters,
29+
* but as we store it not in plain data but base64 encoded the length can grow about 1/3.
30+
* We had a regression with 'Nitrokey 3' which created IDs with 196 byte length -> 262 bytes encoded base64.
31+
* So to be save we increase the size to 512 bytes.
32+
*/
33+
if ($column->getLength() < 512) {
34+
$column->setLength(512);
35+
}
36+
37+
return $schema;
38+
}
39+
}

lib/composer/composer/autoload_classmap.php

+1
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,7 @@
13651365
'OC\\Core\\Migrations\\Version30000Date20240429122720' => $baseDir . '/core/Migrations/Version30000Date20240429122720.php',
13661366
'OC\\Core\\Migrations\\Version30000Date20240708160048' => $baseDir . '/core/Migrations/Version30000Date20240708160048.php',
13671367
'OC\\Core\\Migrations\\Version30000Date20240717111406' => $baseDir . '/core/Migrations/Version30000Date20240717111406.php',
1368+
'OC\\Core\\Migrations\\Version30000Date20240814180800' => $baseDir . '/core/Migrations/Version30000Date20240814180800.php',
13681369
'OC\\Core\\Migrations\\Version30000Date20240815080800' => $baseDir . '/core/Migrations/Version30000Date20240815080800.php',
13691370
'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php',
13701371
'OC\\Core\\ResponseDefinitions' => $baseDir . '/core/ResponseDefinitions.php',

lib/composer/composer/autoload_static.php

+1
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
13981398
'OC\\Core\\Migrations\\Version30000Date20240429122720' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240429122720.php',
13991399
'OC\\Core\\Migrations\\Version30000Date20240708160048' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240708160048.php',
14001400
'OC\\Core\\Migrations\\Version30000Date20240717111406' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240717111406.php',
1401+
'OC\\Core\\Migrations\\Version30000Date20240814180800' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240814180800.php',
14011402
'OC\\Core\\Migrations\\Version30000Date20240815080800' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240815080800.php',
14021403
'OC\\Core\\Notification\\CoreNotifier' => __DIR__ . '/../../..' . '/core/Notification/CoreNotifier.php',
14031404
'OC\\Core\\ResponseDefinitions' => __DIR__ . '/../../..' . '/core/ResponseDefinitions.php',

0 commit comments

Comments
 (0)