Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge AuthenticatorManager and AuthenticatorHandler
The AuthenticatorManager now performs the whole authentication process. This allows for manual authentication without duplicating or publicly exposing parts of the process.
- Loading branch information
Showing
31 changed files
with
590 additions
and
635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 0 additions & 64 deletions
64
src/Symfony/Bundle/SecurityBundle/EventListener/LazyAuthenticatorManagerListener.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 0 additions & 48 deletions
48
src/Symfony/Bundle/SecurityBundle/Security/FirewallAwareAuthenticatorManager.php
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
src/Symfony/Bundle/SecurityBundle/Security/UserAuthenticator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?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\Bundle\SecurityBundle\Security; | ||
|
||
use Psr\Container\ContainerInterface; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Security\Core\Exception\LogicException; | ||
use Symfony\Component\Security\Core\User\UserInterface; | ||
use Symfony\Component\Security\Http\Authentication\UserAuthenticatorInterface; | ||
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface; | ||
|
||
/** | ||
* A decorator that delegates all method calls to the authenticator | ||
* manager of the current firewall. | ||
* | ||
* @author Wouter de Jong <wouter@wouterj.nl> | ||
* | ||
* @final | ||
* @experimental in Symfony 5.1 | ||
*/ | ||
class UserAuthenticator implements UserAuthenticatorInterface | ||
{ | ||
private $firewallMap; | ||
private $userAuthenticators; | ||
private $requestStack; | ||
|
||
public function __construct(FirewallMap $firewallMap, ContainerInterface $userAuthenticators, RequestStack $requestStack) | ||
{ | ||
$this->firewallMap = $firewallMap; | ||
$this->userAuthenticators = $userAuthenticators; | ||
$this->requestStack = $requestStack; | ||
} | ||
|
||
public function authenticateUser(UserInterface $user, AuthenticatorInterface $authenticator, Request $request): ?Response | ||
{ | ||
return $this->getUserAuthenticator()->authenticateUser($user, $authenticator, $request); | ||
} | ||
|
||
private function getUserAuthenticator(): UserAuthenticatorInterface | ||
{ | ||
$firewallConfig = $this->firewallMap->getFirewallConfig($this->requestStack->getMasterRequest()); | ||
if (null === $firewallConfig) { | ||
throw new LogicException('Cannot call authenticate on this request, as it is not behind a firewall.'); | ||
} | ||
|
||
return $this->userAuthenticators->get($firewallConfig->getName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.