Skip to content

Commit 9e24a71

Browse files
Check whether secrets are empty and mark them all as sensitive
1 parent 8ff1a32 commit 9e24a71

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Authentication/Token/RememberMeToken.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Core\Authentication\Token;
1313

14+
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
1415
use Symfony\Component\Security\Core\User\UserInterface;
1516

1617
/**
@@ -32,12 +33,12 @@ public function __construct(UserInterface $user, string $firewallName, #[\Sensit
3233
{
3334
parent::__construct($user->getRoles());
3435

35-
if (empty($secret)) {
36-
throw new \InvalidArgumentException('$secret must not be empty.');
36+
if (!$secret) {
37+
throw new InvalidArgumentException('A non-empty secret is required.');
3738
}
3839

39-
if ('' === $firewallName) {
40-
throw new \InvalidArgumentException('$firewallName must not be empty.');
40+
if (!$firewallName) {
41+
throw new InvalidArgumentException('$firewallName must not be empty.');
4142
}
4243

4344
$this->firewallName = $firewallName;

Signature/SignatureHasher.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Core\Signature;
1313

1414
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
15+
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
1516
use Symfony\Component\Security\Core\Signature\Exception\ExpiredSignatureException;
1617
use Symfony\Component\Security\Core\Signature\Exception\InvalidSignatureException;
1718
use Symfony\Component\Security\Core\User\UserInterface;
@@ -37,6 +38,10 @@ class SignatureHasher
3738
*/
3839
public function __construct(PropertyAccessorInterface $propertyAccessor, array $signatureProperties, #[\SensitiveParameter] string $secret, ExpiredSignatureStorage $expiredSignaturesStorage = null, int $maxUses = null)
3940
{
41+
if (!$secret) {
42+
throw new InvalidArgumentException('A non-empty secret is required.');
43+
}
44+
4045
$this->propertyAccessor = $propertyAccessor;
4146
$this->signatureProperties = $signatureProperties;
4247
$this->secret = $secret;

0 commit comments

Comments
 (0)