From e8f83f188a238da8ff0cd0567c88c302c80f4a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Thu, 9 Apr 2020 15:17:46 +0200 Subject: [PATCH] Fixed issue that U2F keys did not work. The DB length for this field was too short, so the key handles were cut off and devices were not recognized. --- src/Entity/UserSystem/U2FKey.php | 6 ++-- src/Migrations/Version20200409130946.php | 35 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 src/Migrations/Version20200409130946.php diff --git a/src/Entity/UserSystem/U2FKey.php b/src/Entity/UserSystem/U2FKey.php index 151fa980..f9dd301f 100644 --- a/src/Entity/UserSystem/U2FKey.php +++ b/src/Entity/UserSystem/U2FKey.php @@ -59,15 +59,15 @@ class U2FKey implements TwoFactorKeyInterface use TimestampTrait; /** - * @ORM\Column(type="string", length=64) - * + * We have to restrict the length here, as InnoDB only supports key index with max. 767 Bytes. + * Max length of keyhandles should be 128. (According to U2F_MAX_KH_SIZE in FIDO example C code). + * @ORM\Column(type="string", length=128) * @var string **/ public $keyHandle; /** * @ORM\Column(type="string") - * * @var string **/ public $publicKey; diff --git a/src/Migrations/Version20200409130946.php b/src/Migrations/Version20200409130946.php new file mode 100644 index 00000000..64bf246f --- /dev/null +++ b/src/Migrations/Version20200409130946.php @@ -0,0 +1,35 @@ +abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE u2f_keys CHANGE key_handle key_handle VARCHAR(128) NOT NULL'); + } + + public function down(Schema $schema) : void + { + // this down() migration is auto-generated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE u2f_keys CHANGE key_handle key_handle VARCHAR(64) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`'); + } +}