Add passport to AuthenticationTokenCreatedEvent
This commit is contained in:
parent
d7007d7785
commit
74196e0750
@ -6,6 +6,7 @@ The CHANGELOG for version 5.4 and newer can be found in the security sub-package
|
||||
5.3
|
||||
---
|
||||
|
||||
* Add `getPassport()` method and a second `$passport` constructor argument to `AuthenticationTokenCreatedEvent`
|
||||
* The authenticator system is no longer experimental
|
||||
* Login Link functionality is no longer experimental
|
||||
* Add `RememberMeConditionsListener` to check if remember me is requested and supported, and set priority of `RememberMeListener` to -63
|
||||
|
@ -74,7 +74,7 @@ class AuthenticatorManager implements AuthenticatorManagerInterface, UserAuthent
|
||||
$token = $authenticator->createAuthenticatedToken($passport = new SelfValidatingPassport(new UserBadge(method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername(), function () use ($user) { return $user; }), $badges), $this->firewallName);
|
||||
|
||||
// announce the authenticated token
|
||||
$token = $this->eventDispatcher->dispatch(new AuthenticationTokenCreatedEvent($token))->getAuthenticatedToken();
|
||||
$token = $this->eventDispatcher->dispatch(new AuthenticationTokenCreatedEvent($token, $passport))->getAuthenticatedToken();
|
||||
|
||||
// authenticate this in the system
|
||||
return $this->handleAuthenticationSuccess($token, $passport, $request, $authenticator);
|
||||
@ -188,7 +188,7 @@ class AuthenticatorManager implements AuthenticatorManagerInterface, UserAuthent
|
||||
$authenticatedToken = $authenticator->createAuthenticatedToken($passport, $this->firewallName);
|
||||
|
||||
// announce the authenticated token
|
||||
$authenticatedToken = $this->eventDispatcher->dispatch(new AuthenticationTokenCreatedEvent($authenticatedToken))->getAuthenticatedToken();
|
||||
$authenticatedToken = $this->eventDispatcher->dispatch(new AuthenticationTokenCreatedEvent($authenticatedToken, $passport))->getAuthenticatedToken();
|
||||
|
||||
if (true === $this->eraseCredentials) {
|
||||
$authenticatedToken->eraseCredentials();
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Security\Http\Event;
|
||||
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
|
||||
use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
@ -22,10 +23,12 @@ use Symfony\Contracts\EventDispatcher\Event;
|
||||
class AuthenticationTokenCreatedEvent extends Event
|
||||
{
|
||||
private $authenticatedToken;
|
||||
private $passport;
|
||||
|
||||
public function __construct(TokenInterface $token)
|
||||
public function __construct(TokenInterface $token, PassportInterface $passport)
|
||||
{
|
||||
$this->authenticatedToken = $token;
|
||||
$this->passport = $passport;
|
||||
}
|
||||
|
||||
public function getAuthenticatedToken(): TokenInterface
|
||||
@ -37,4 +40,9 @@ class AuthenticationTokenCreatedEvent extends Event
|
||||
{
|
||||
$this->authenticatedToken = $authenticatedToken;
|
||||
}
|
||||
|
||||
public function getPassport(): PassportInterface
|
||||
{
|
||||
return $this->passport;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user