Applied left-over review comments from #33558
This commit is contained in:
parent
6b682bfcc5
commit
be3a9a93f0
@ -77,7 +77,7 @@ class AuthenticatorManager implements AuthenticatorManagerInterface, UserAuthent
|
|||||||
public function supports(Request $request): ?bool
|
public function supports(Request $request): ?bool
|
||||||
{
|
{
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$context = ['firewall_key' => $this->firewallName];
|
$context = ['firewall_name' => $this->firewallName];
|
||||||
|
|
||||||
if ($this->authenticators instanceof \Countable || \is_array($this->authenticators)) {
|
if ($this->authenticators instanceof \Countable || \is_array($this->authenticators)) {
|
||||||
$context['authenticators'] = \count($this->authenticators);
|
$context['authenticators'] = \count($this->authenticators);
|
||||||
@ -90,14 +90,14 @@ class AuthenticatorManager implements AuthenticatorManagerInterface, UserAuthent
|
|||||||
$lazy = true;
|
$lazy = true;
|
||||||
foreach ($this->authenticators as $authenticator) {
|
foreach ($this->authenticators as $authenticator) {
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->debug('Checking support on authenticator.', ['firewall_key' => $this->firewallName, 'authenticator' => \get_class($authenticator)]);
|
$this->logger->debug('Checking support on authenticator.', ['firewall_name' => $this->firewallName, 'authenticator' => \get_class($authenticator)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false !== $supports = $authenticator->supports($request)) {
|
if (false !== $supports = $authenticator->supports($request)) {
|
||||||
$authenticators[] = $authenticator;
|
$authenticators[] = $authenticator;
|
||||||
$lazy = $lazy && null === $supports;
|
$lazy = $lazy && null === $supports;
|
||||||
} elseif (null !== $this->logger) {
|
} elseif (null !== $this->logger) {
|
||||||
$this->logger->debug('Authenticator does not support the request.', ['firewall_key' => $this->firewallName, 'authenticator' => \get_class($authenticator)]);
|
$this->logger->debug('Authenticator does not support the request.', ['firewall_name' => $this->firewallName, 'authenticator' => \get_class($authenticator)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
|||||||
*
|
*
|
||||||
* This is used to not break AuthenticationChecker and ContextListener when
|
* This is used to not break AuthenticationChecker and ContextListener when
|
||||||
* using the authenticator system. Once the authenticator system is no longer
|
* using the authenticator system. Once the authenticator system is no longer
|
||||||
* experimental, this class can be used trigger deprecation notices.
|
* experimental, this class can be used to trigger deprecation notices.
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*
|
*
|
||||||
|
@ -24,7 +24,7 @@ use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
|
|||||||
interface UserAuthenticatorInterface
|
interface UserAuthenticatorInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Convenience method to manually login a user and return a
|
* Convenience method to programmatically login a user and return a
|
||||||
* Response *if any* for success.
|
* Response *if any* for success.
|
||||||
*/
|
*/
|
||||||
public function authenticateUser(UserInterface $user, AuthenticatorInterface $authenticator, Request $request): ?Response;
|
public function authenticateUser(UserInterface $user, AuthenticatorInterface $authenticator, Request $request): ?Response;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Security\Http\Authenticator\Passport\Badge;
|
namespace Symfony\Component\Security\Http\Authenticator\Passport\Badge;
|
||||||
|
|
||||||
|
use Symfony\Component\Security\Core\Exception\LogicException;
|
||||||
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,9 +39,16 @@ class PasswordUpgradeBadge implements BadgeInterface
|
|||||||
$this->passwordUpgrader = $passwordUpgrader;
|
$this->passwordUpgrader = $passwordUpgrader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPlaintextPassword(): string
|
public function getAndErasePlaintextPassword(): string
|
||||||
{
|
{
|
||||||
return $this->plaintextPassword;
|
$password = $this->plaintextPassword;
|
||||||
|
if (null === $password) {
|
||||||
|
throw new LogicException('The password is erased as another listener already used this badge.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->plaintextPassword = null;
|
||||||
|
|
||||||
|
return $password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPasswordUpgrader(): PasswordUpgraderInterface
|
public function getPasswordUpgrader(): PasswordUpgraderInterface
|
||||||
@ -48,14 +56,6 @@ class PasswordUpgradeBadge implements BadgeInterface
|
|||||||
return $this->passwordUpgrader;
|
return $this->passwordUpgrader;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
public function eraseCredentials()
|
|
||||||
{
|
|
||||||
$this->plaintextPassword = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isResolved(): bool
|
public function isResolved(): bool
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Symfony\Component\Security\Http\EventListener;
|
namespace Symfony\Component\Security\Http\EventListener;
|
||||||
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
@ -32,8 +41,7 @@ class PasswordMigratingListener implements EventSubscriberInterface
|
|||||||
|
|
||||||
/** @var PasswordUpgradeBadge $badge */
|
/** @var PasswordUpgradeBadge $badge */
|
||||||
$badge = $passport->getBadge(PasswordUpgradeBadge::class);
|
$badge = $passport->getBadge(PasswordUpgradeBadge::class);
|
||||||
$plaintextPassword = $badge->getPlaintextPassword();
|
$plaintextPassword = $badge->getAndErasePlaintextPassword();
|
||||||
$badge->eraseCredentials();
|
|
||||||
|
|
||||||
if ('' === $plaintextPassword) {
|
if ('' === $plaintextPassword) {
|
||||||
return;
|
return;
|
||||||
|
@ -17,7 +17,7 @@ use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategy;
|
|||||||
use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface;
|
use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Migrates/invalidate the session after successful login.
|
* Migrates/invalidates the session after successful login.
|
||||||
*
|
*
|
||||||
* This should be registered as subscriber to any "stateful" firewalls.
|
* This should be registered as subscriber to any "stateful" firewalls.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user