Skip to content

Commit 21661fb

Browse files
GromNaNfabpot
authored andcommitted
Hide sensitive information with SensitiveParameter attribute
1 parent cebe5e9 commit 21661fb

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

Authentication/RememberMe/CacheTokenVerifier.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(CacheItemPoolInterface $cache, int $outdatedTokenTtl
3838
/**
3939
* {@inheritdoc}
4040
*/
41-
public function verifyToken(PersistentTokenInterface $token, string $tokenValue): bool
41+
public function verifyToken(PersistentTokenInterface $token, #[\SensitiveParameter] string $tokenValue): bool
4242
{
4343
if (hash_equals($token->getTokenValue(), $tokenValue)) {
4444
return true;
@@ -58,7 +58,7 @@ public function verifyToken(PersistentTokenInterface $token, string $tokenValue)
5858
/**
5959
* {@inheritdoc}
6060
*/
61-
public function updateExistingToken(PersistentTokenInterface $token, string $tokenValue, \DateTimeInterface $lastUsed): void
61+
public function updateExistingToken(PersistentTokenInterface $token, #[\SensitiveParameter] string $tokenValue, \DateTimeInterface $lastUsed): void
6262
{
6363
// When a token gets updated, persist the outdated token for $outdatedTokenTtl seconds so we can
6464
// still accept it as valid in verifyToken

Authentication/RememberMe/InMemoryTokenProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function loadTokenBySeries(string $series): PersistentTokenInterface
3737
/**
3838
* {@inheritdoc}
3939
*/
40-
public function updateToken(string $series, string $tokenValue, \DateTime $lastUsed)
40+
public function updateToken(string $series, #[\SensitiveParameter] string $tokenValue, \DateTime $lastUsed)
4141
{
4242
if (!isset($this->tokens[$series])) {
4343
throw new TokenNotFoundException('No token found.');

Authentication/RememberMe/PersistentToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class PersistentToken implements PersistentTokenInterface
2424
private string $tokenValue;
2525
private \DateTime $lastUsed;
2626

27-
public function __construct(string $class, string $userIdentifier, string $series, string $tokenValue, \DateTime $lastUsed)
27+
public function __construct(string $class, string $userIdentifier, string $series, #[\SensitiveParameter] string $tokenValue, \DateTime $lastUsed)
2828
{
2929
if (empty($class)) {
3030
throw new \InvalidArgumentException('$class must not be empty.');

Authentication/RememberMe/TokenProviderInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function deleteTokenBySeries(string $series);
3939
*
4040
* @throws TokenNotFoundException if the token is not found
4141
*/
42-
public function updateToken(string $series, string $tokenValue, \DateTime $lastUsed);
42+
public function updateToken(string $series, #[\SensitiveParameter] string $tokenValue, \DateTime $lastUsed);
4343

4444
/**
4545
* Creates a new token.

Authentication/RememberMe/TokenVerifierInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ interface TokenVerifierInterface
2323
*
2424
* Do not forget to implement token comparisons using hash_equals for a secure implementation.
2525
*/
26-
public function verifyToken(PersistentTokenInterface $token, string $tokenValue): bool;
26+
public function verifyToken(PersistentTokenInterface $token, #[\SensitiveParameter] string $tokenValue): bool;
2727

2828
/**
2929
* Updates an existing token with a new token value and lastUsed time.
3030
*/
31-
public function updateExistingToken(PersistentTokenInterface $token, string $tokenValue, \DateTimeInterface $lastUsed): void;
31+
public function updateExistingToken(PersistentTokenInterface $token, #[\SensitiveParameter] string $tokenValue, \DateTimeInterface $lastUsed): void;
3232
}

Authentication/Token/RememberMeToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RememberMeToken extends AbstractToken
2828
*
2929
* @throws \InvalidArgumentException
3030
*/
31-
public function __construct(UserInterface $user, string $firewallName, string $secret)
31+
public function __construct(UserInterface $user, string $firewallName, #[\SensitiveParameter] string $secret)
3232
{
3333
parent::__construct($user->getRoles());
3434

Signature/SignatureHasher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SignatureHasher
3535
* @param ExpiredSignatureStorage|null $expiredSignaturesStorage if provided, secures a sequence of hashes that are expired
3636
* @param int|null $maxUses used together with $expiredSignatureStorage to allow a maximum usage of a hash
3737
*/
38-
public function __construct(PropertyAccessorInterface $propertyAccessor, array $signatureProperties, string $secret, ExpiredSignatureStorage $expiredSignaturesStorage = null, int $maxUses = null)
38+
public function __construct(PropertyAccessorInterface $propertyAccessor, array $signatureProperties, #[\SensitiveParameter] string $secret, ExpiredSignatureStorage $expiredSignaturesStorage = null, int $maxUses = null)
3939
{
4040
$this->propertyAccessor = $propertyAccessor;
4141
$this->signatureProperties = $signatureProperties;

0 commit comments

Comments
 (0)