Skip to content

Commit

Permalink
BE and BS flags support (#424)
Browse files Browse the repository at this point in the history
BE and BS flags support
  • Loading branch information
Spomky committed Jun 21, 2023
1 parent e8d6be7 commit 86647fd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
18 changes: 13 additions & 5 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
18 changes: 18 additions & 0 deletions src/webauthn/src/AuthenticatorData.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

/**
* @see https://www.w3.org/TR/webauthn/#sec-authenticator-data
* @see https://www.w3.org/TR/webauthn/#flags
*/
class AuthenticatorData
{
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions tests/library/Functional/AttestationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 86647fd

Please sign in to comment.