1
0

Version30000Date20240814180800.php 1.3 KB

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