From a0a7448472d9cebc1a6b76b095ec8bb50e0c6d6e Mon Sep 17 00:00:00 2001 From: Johan Kromhout Date: Tue, 7 Jan 2025 07:41:29 +0100 Subject: [PATCH] Fix: Implement PublicKeyCredentialSource schema changes Prior to this change, the PublicKeyCredentialSource entity could not be saved, because a 3rd party web authn package which we extend PublicKeyCredentialSource from has new db fields. This resulted in sql errors. This change implements the required fields and adds a migration. Fixes https://github.com/OpenConext/Stepup-Webauthn/issues/143 Caused by https://github.com/OpenConext/Stepup-Webauthn/commit/dd32c2654bc3170c31c186f9ccf6033d95bbcdab#diff-d2ab9925cad7eac58e0ff4cc0d251a937ecf49e4b6bf57f8b95aab76648a9d34R37 See https://github.com/web-auth/webauthn-framework/pull/592 See https://github.com/web-auth/webauthn-framework/releases/tag/4.8.6 --- src/Entity/PublicKeyCredentialSource.php | 6 ++- src/Migrations/Version20250106150814.php | 47 ++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 src/Migrations/Version20250106150814.php diff --git a/src/Entity/PublicKeyCredentialSource.php b/src/Entity/PublicKeyCredentialSource.php index 8ff4f7b7..0a3e1dbd 100644 --- a/src/Entity/PublicKeyCredentialSource.php +++ b/src/Entity/PublicKeyCredentialSource.php @@ -38,12 +38,14 @@ class PublicKeyCredentialSource extends BasePublicKeyCredentialSource #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type:"integer")] - private string $id; + private int $id; /** - * Override the $uvInitialized field which we do not use, but needs + * Override the $backupEligible, $backupStatus and $uvInitialized fields which we do not use, but needs * to be initialized. Needed to prevent read before written errors. */ + public ?bool $backupEligible = null; + public ?bool $backupStatus = null; public ?bool $uvInitialized = false; public function __construct( diff --git a/src/Migrations/Version20250106150814.php b/src/Migrations/Version20250106150814.php new file mode 100644 index 00000000..df8971ab --- /dev/null +++ b/src/Migrations/Version20250106150814.php @@ -0,0 +1,47 @@ +addSql('ALTER TABLE public_key_credential_sources ADD backup_eligible TINYINT(1) DEFAULT NULL, ADD backup_status TINYINT(1) DEFAULT NULL, ADD uv_initialized TINYINT(1) DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE public_key_credential_sources DROP backup_eligible, DROP backup_status, DROP uv_initialized'); + } +}