Skip to content

Commit

Permalink
BS and BE flags added to the Symfony Token (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spomky committed Jun 21, 2023
1 parent 86647fd commit 49b5bbc
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
18 changes: 18 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,14 @@ parameters:
count: 1
path: src/symfony/src/Resources/config/services.php

-
message: """
#^Class Webauthn\\\\Bundle\\\\Security\\\\Authentication\\\\Token\\\\WebauthnToken implements deprecated interface Webauthn\\\\Bundle\\\\Security\\\\Authentication\\\\Token\\\\WebauthnTokenInterface\\:
since 4\\.7\\.0, use \\{@see \\\\Webauthn\\\\Bundle\\\\Security\\\\Authentication\\\\Token\\\\WebauthnTokenInterface\\} instead$#
"""
count: 1
path: src/symfony/src/Security/Authentication/Token/WebauthnToken.php

-
message: "#^Parameter \\#1 \\$data of method Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\AbstractToken\\:\\:__unserialize\\(\\) expects array, mixed given\\.$#"
count: 1
Expand Down Expand Up @@ -951,6 +959,16 @@ parameters:
count: 1
path: src/symfony/src/Security/Authentication/Token/WebauthnToken.php

-
message: "#^Property Webauthn\\\\Bundle\\\\Security\\\\Authentication\\\\Token\\\\WebauthnToken\\:\\:\\$isBackedUp \\(bool\\) does not accept mixed\\.$#"
count: 1
path: src/symfony/src/Security/Authentication/Token/WebauthnToken.php

-
message: "#^Property Webauthn\\\\Bundle\\\\Security\\\\Authentication\\\\Token\\\\WebauthnToken\\:\\:\\$isBackupEligible \\(bool\\) does not accept mixed\\.$#"
count: 1
path: src/symfony/src/Security/Authentication/Token/WebauthnToken.php

-
message: "#^Property Webauthn\\\\Bundle\\\\Security\\\\Authentication\\\\Token\\\\WebauthnToken\\:\\:\\$isUserPresent \\(bool\\) does not accept mixed\\.$#"
count: 1
Expand Down
18 changes: 17 additions & 1 deletion src/symfony/src/Security/Authentication/Token/WebauthnToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public function __construct(
private readonly int $signCount,
private ?AuthenticationExtensionsClientOutputs $extensions,
private readonly string $firewallName,
array $roles = []
array $roles = [],
private bool $isBackupEligible = false,
private bool $isBackedUp = false,
) {
parent::__construct($roles);
}
Expand All @@ -47,6 +49,8 @@ public function __serialize(): array
json_encode($this->publicKeyCredentialOptions, JSON_THROW_ON_ERROR),
$this->isUserPresent,
$this->isUserVerified,
$this->isBackupEligible,
$this->isBackedUp,
$this->reservedForFutureUse1,
$this->reservedForFutureUse2,
$this->signCount,
Expand All @@ -68,6 +72,8 @@ public function __unserialize(array $serialized): void
$publicKeyCredentialOptions,
$this->isUserPresent,
$this->isUserVerified,
$this->isBackupEligible,
$this->isBackedUp,
$this->reservedForFutureUse1,
$this->reservedForFutureUse2,
$this->signCount,
Expand Down Expand Up @@ -141,6 +147,16 @@ public function getSignCount(): int
return $this->signCount;
}

public function isBackupEligible(): bool
{
return $this->isBackupEligible;
}

public function isBackedUp(): bool
{
return $this->isBackedUp;
}

public function getExtensions(): ?AuthenticationExtensionsClientOutputs
{
return $this->extensions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use Webauthn\PublicKeyCredentialOptions;
use Webauthn\PublicKeyCredentialUserEntity;

/**
* @deprecated since 4.7.0, use {@see \Webauthn\Bundle\Security\Authentication\Token\WebauthnTokenInterface} instead
*/
interface WebauthnTokenInterface extends TokenInterface
{
public function getCredentials(): PublicKeyCredentialDescriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ public function createToken(Passport $passport, string $firewallName): TokenInte
$authData->getExtensions(),
$credentialsBadge->getFirewallName(),
$userBadge->getUser()
->getRoles()
->getRoles(),
$authData->isBackupEligible(),
$authData->isBackedUp(),
);
$token->setUser($userBadge->getUser());
return $token;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ private function logIn(): void
100,
null,
$firewallName,
$user->getRoles()
$user->getRoles(),
true,
true
);
$token->setUser($user);

Expand Down

0 comments on commit 49b5bbc

Please sign in to comment.