diff --git a/rector.php b/rector.php index 8ffd55dd..a231e8d6 100644 --- a/rector.php +++ b/rector.php @@ -6,6 +6,8 @@ use Rector\Core\ValueObject\PhpVersion; use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector; use Rector\Doctrine\Set\DoctrineSetList; +use Rector\Php81\Rector\Property\ReadOnlyPropertyRector; +use Rector\PHPUnit\Rector\Class_\PreferPHPUnitThisCallRector; use Rector\PHPUnit\Set\PHPUnitLevelSetList; use Rector\PHPUnit\Set\PHPUnitSetList; use Rector\Set\ValueObject\LevelSetList; @@ -23,19 +25,25 @@ $config->import(SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES); $config->import(DoctrineSetList::DOCTRINE_CODE_QUALITY); $config->import(DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES); + $config->import(PHPUnitSetList::PHPUNIT_CODE_QUALITY); $config->import(PHPUnitSetList::PHPUNIT_EXCEPTION); + $config->import(PHPUnitSetList::REMOVE_MOCKS); $config->import(PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD); + $config->import(PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES); $config->import(PHPUnitLevelSetList::UP_TO_PHPUNIT_100); - $config->import(PHPUnitSetList::PHPUNIT_YIELD_DATA_PROVIDER); $config->paths([__DIR__ . '/src', __DIR__ . '/tests']); $config->skip([ - 'src/symfony/src/DependencyInjection/Configuration.php', - 'src/symfony/src/Routing/Loader.php', - 'tests/symfony/config/routing.php', + __DIR__ . '/src/symfony/src/DependencyInjection/Configuration.php', + __DIR__ . '/src/symfony/src/Routing/Loader.php', + __DIR__ . '/tests/symfony/config/routing.php', RemoveUnusedPrivateMethodParameterRector::class => [ - __DIR__ . '*/DependencyInjection/Configuration.php', + __DIR__ . '/src/symfony/src/DependencyInjection/Configuration.php', + ], + ReadOnlyPropertyRector::class => [ + __DIR__ . '/src/metadata-service/src/Statement/MetadataStatement.php', ], ]); + $config->services()->remove(PreferPHPUnitThisCallRector::class); $config->phpVersion(PhpVersion::PHP_81); $config->parallel(); $config->importNames(); diff --git a/src/webauthn/src/AuthenticatorData.php b/src/webauthn/src/AuthenticatorData.php index 89e24134..d292a4ee 100644 --- a/src/webauthn/src/AuthenticatorData.php +++ b/src/webauthn/src/AuthenticatorData.php @@ -9,6 +9,7 @@ /** * @see https://www.w3.org/TR/webauthn/#sec-authenticator-data + * @see https://www.w3.org/TR/webauthn/#flags */ class AuthenticatorData { @@ -18,6 +19,13 @@ class AuthenticatorData private const FLAG_UV = 0b00000100; + private const FLAG_BE = 0b00001000; + + private const FLAG_BS = 0b00010000; + + /** + * TODO: remove bits 3 and 4 as they have been assigned to BE and BS in Webauthn level 3. + */ private const FLAG_RFU2 = 0b00111000; private const FLAG_AT = 0b01000000; @@ -54,6 +62,16 @@ public function isUserVerified(): bool return 0 !== (ord($this->flags) & self::FLAG_UV); } + public function isBackupEligible(): bool + { + return 0 !== (ord($this->flags) & self::FLAG_BE); + } + + public function isBackedUp(): bool + { + return 0 !== (ord($this->flags) & self::FLAG_BS); + } + public function hasAttestedCredentialData(): bool { return 0 !== (ord($this->flags) & self::FLAG_AT); diff --git a/tests/library/Functional/AttestationTest.php b/tests/library/Functional/AttestationTest.php index a1d04924..e87a80df 100644 --- a/tests/library/Functional/AttestationTest.php +++ b/tests/library/Functional/AttestationTest.php @@ -69,6 +69,8 @@ public function anAttestationSignedWithEcDSA521ShouldBeVerified(): void ); static::assertTrue($authenticatorData->isUserPresent()); static::assertFalse($authenticatorData->isUserVerified()); + static::assertFalse($authenticatorData->isBackupEligible()); + static::assertFalse($authenticatorData->isBackedUp()); static::assertTrue($authenticatorData->hasAttestedCredentialData()); static::assertSame(0, $authenticatorData->getReservedForFutureUse1()); static::assertSame(0, $authenticatorData->getReservedForFutureUse2());