Skip to content

Commit

Permalink
Fix: Implement PublicKeyCredentialSource schema changes
Browse files Browse the repository at this point in the history
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 #143
Caused by dd32c26#diff-d2ab9925cad7eac58e0ff4cc0d251a937ecf49e4b6bf57f8b95aab76648a9d34R37

See web-auth/webauthn-framework#592
See https://github.com/web-auth/webauthn-framework/releases/tag/4.8.6
  • Loading branch information
johanib committed Jan 7, 2025
1 parent 866b1b0 commit b59c8b9
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
5 changes: 0 additions & 5 deletions ci/qa/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,3 @@ parameters:
message: "#^Method Surfnet\\\\Webauthn\\\\WithContextLogger\\:\\:from\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/WithContextLogger.php

-
message: "#^Method Surfnet\\\\Webauthn\\\\WithContextLogger\\:\\:log\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/WithContextLogger.php
6 changes: 4 additions & 2 deletions src/Entity/PublicKeyCredentialSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
47 changes: 47 additions & 0 deletions src/Migrations/Version20250106150814.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

/**
* Copyright 2024 SURFnet B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* @SuppressWarnings(PHPMD)
*/
final class Version20250106150814 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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');
}
}

0 comments on commit b59c8b9

Please sign in to comment.