Skip to content

[Security] Throw when passing an empty string as $userIdentifier and tighten AuthenticatorManager and OidcTokenHandler arguments #61183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion UPGRADE-8.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,9 @@ Security
+ return $data;
+}
```

* Throw a `BadCredentialsException` when passing an empty string as `$userIdentifier` argument to `UserBadge` constructor
* Accept only `ExposeSecurityLevel` enums for `AuthenticatorManager`'s `$exposeSecurityErrors` argument
* Respectively accept only `AlgorithmManager` and `JWKSet` for `OidcTokenHandler`'s `$signatureAlgorithm` and `$signatureKeyset` arguments
* Remove callable firewall listeners support, extend `AbstractListener` or implement `FirewallListenerInterface` instead
* Remove `AbstractListener::__invoke`
* Remove `LazyFirewallContext::__invoke()`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

use Jose\Component\Checker;
use Jose\Component\Checker\ClaimCheckerManager;
use Jose\Component\Core\Algorithm;
use Jose\Component\Core\AlgorithmManager;
use Jose\Component\Core\JWK;
use Jose\Component\Core\JWKSet;
use Jose\Component\Encryption\JWEDecrypter;
use Jose\Component\Encryption\JWETokenSupport;
Expand Down Expand Up @@ -53,22 +51,14 @@ final class OidcTokenHandler implements AccessTokenHandlerInterface
private ?string $oidcJWKSetCacheKey = null;

public function __construct(
private Algorithm|AlgorithmManager $signatureAlgorithm,
private JWK|JWKSet|null $signatureKeyset,
private AlgorithmManager $signatureAlgorithm,
private ?JWKSet $signatureKeyset,
private string $audience,
private array $issuers,
private string $claim = 'sub',
private ?LoggerInterface $logger = null,
private ClockInterface $clock = new Clock(),
) {
if ($signatureAlgorithm instanceof Algorithm) {
trigger_deprecation('symfony/security-http', '7.1', 'First argument must be instance of %s, %s given.', AlgorithmManager::class, Algorithm::class);
$this->signatureAlgorithm = new AlgorithmManager([$signatureAlgorithm]);
}
if ($signatureKeyset instanceof JWK) {
trigger_deprecation('symfony/security-http', '7.1', 'Second argument must be instance of %s, %s given.', JWKSet::class, JWK::class);
$this->signatureKeyset = new JWKSet([$signatureKeyset]);
}
}

public function enableJweSupport(JWKSet $decryptionKeyset, AlgorithmManager $decryptionAlgorithms, bool $enforceEncryption): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
*/
class AuthenticatorManager implements AuthenticatorManagerInterface, UserAuthenticatorInterface
{
private ExposeSecurityLevel $exposeSecurityErrors;

/**
* @param iterable<mixed, AuthenticatorInterface> $authenticators
*/
Expand All @@ -59,17 +57,9 @@ public function __construct(
private string $firewallName,
private ?LoggerInterface $logger = null,
private bool $eraseCredentials = true,
ExposeSecurityLevel|bool $exposeSecurityErrors = ExposeSecurityLevel::None,
private ExposeSecurityLevel $exposeSecurityErrors = ExposeSecurityLevel::None,
private array $requiredBadges = [],
) {
if (\is_bool($exposeSecurityErrors)) {
trigger_deprecation('symfony/security-http', '7.3', 'Passing a boolean as "exposeSecurityErrors" parameter is deprecated, use %s value instead.', ExposeSecurityLevel::class);

// The old parameter had an inverted meaning ($hideUserNotFoundExceptions), for that reason the current name does not reflect the behavior
$exposeSecurityErrors = $exposeSecurityErrors ? ExposeSecurityLevel::None : ExposeSecurityLevel::All;
}

$this->exposeSecurityErrors = $exposeSecurityErrors;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public function __construct(
?\Closure $identifierNormalizer = null,
) {
if ('' === $userIdentifier) {
trigger_deprecation('symfony/security-http', '7.2', 'Using an empty string as user identifier is deprecated and will throw an exception in Symfony 8.0.');
// throw new BadCredentialsException('Empty user identifier.');
throw new BadCredentialsException('Empty user identifier.');
}

if (\strlen($userIdentifier) > self::MAX_USERNAME_LENGTH) {
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Security/Http/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ CHANGELOG

* Remove callable firewall listeners support, extend `AbstractListener` or implement `FirewallListenerInterface` instead
* Remove `AbstractListener::__invoke`
* Throw a `BadCredentialsException` when passing an empty string as `$userIdentifier` argument to `UserBadge` constructor
* Accept only `ExposeSecurityLevel` enums for `AuthenticatorManager`'s `$exposeSecurityErrors` argument
* Respectively accept only `AlgorithmManager` and `JWKSet` for `OidcTokenHandler`'s `$signatureAlgorithm` and `$signatureKeyset` arguments

7.4
---
Expand Down
Loading
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy