Skip to content

Commit 073e568

Browse files
Check whether secrets are empty and mark them all as sensitive
1 parent 6b771ff commit 073e568

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Authenticator/RememberMeAuthenticator.php

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
2020
use Symfony\Component\Security\Core\Exception\AuthenticationException;
2121
use Symfony\Component\Security\Core\Exception\CookieTheftException;
22+
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
2223
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
2324
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
2425
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
@@ -51,6 +52,10 @@ class RememberMeAuthenticator implements InteractiveAuthenticatorInterface
5152

5253
public function __construct(RememberMeHandlerInterface $rememberMeHandler, #[\SensitiveParameter] string $secret, TokenStorageInterface $tokenStorage, string $cookieName, LoggerInterface $logger = null)
5354
{
55+
if (!$secret) {
56+
throw new InvalidArgumentException('A non-empty secret is required.');
57+
}
58+
5459
$this->rememberMeHandler = $rememberMeHandler;
5560
$this->secret = $secret;
5661
$this->tokenStorage = $tokenStorage;

RateLimiter/DefaultLoginRateLimiter.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\HttpFoundation\RateLimiter\AbstractRequestRateLimiter;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\RateLimiter\RateLimiterFactory;
17+
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
1718
use Symfony\Component\Security\Http\SecurityRequestAttributes;
1819

1920
/**
@@ -35,10 +36,10 @@ final class DefaultLoginRateLimiter extends AbstractRequestRateLimiter
3536
*/
3637
public function __construct(RateLimiterFactory $globalFactory, RateLimiterFactory $localFactory, #[\SensitiveParameter] string $secret = '')
3738
{
38-
if ('' === $secret) {
39-
trigger_deprecation('symfony/security-http', '6.4', 'Calling "%s()" with an empty secret is deprecated. A non-empty secret will be mandatory in version 7.0.', __METHOD__);
40-
// throw new \Symfony\Component\Security\Core\Exception\InvalidArgumentException('A non-empty secret is required.');
39+
if (!$secret) {
40+
throw new InvalidArgumentException('A non-empty secret is required.');
4141
}
42+
4243
$this->globalFactory = $globalFactory;
4344
$this->localFactory = $localFactory;
4445
$this->secret = $secret;

0 commit comments

Comments
 (0)