AbstractAuthenticationListener
extends AbstractListener
in package
implements
ListenerInterface
Uses
LegacyListenerTrait
The AbstractAuthenticationListener is the preferred base class for all browser-/HTTP-based authentication requests.
Subclasses likely have to implement the following:
- an TokenInterface to hold authentication related data
- an AuthenticationProvider to perform the actual authentication of the token, retrieve the UserInterface implementation from a database, and perform the specific account checks using the UserChecker
By default, this listener only is active for a specific path, e.g. /login_check. If you want to change this behavior, you can overwrite the requiresAuthentication() method.
Tags
Interfaces, Classes, Traits and Enums
- ListenerInterface
- Interface that must be implemented by firewall listeners.
Table of Contents
- $authenticationManager : mixed
- $httpUtils : mixed
- $logger : mixed
- $options : mixed
- $providerKey : mixed
- $dispatcher : mixed
- $failureHandler : mixed
- $rememberMeServices : mixed
- $sessionStrategy : mixed
- $successHandler : mixed
- $tokenStorage : mixed
- __construct() : mixed
- __invoke() : mixed
- authenticate() : mixed
- Handles form based authentication.
- setRememberMeServices() : mixed
- Sets the RememberMeServices implementation to use.
- supports() : bool|null
- Tells whether the authenticate() method should be called or not depending on the incoming request.
- attemptAuthentication() : TokenInterface|Response|null
- Performs authentication.
- requiresAuthentication() : bool
- Whether this request requires authentication.
- onFailure() : Response
- onSuccess() : Response
Properties
$authenticationManager
protected
mixed
$authenticationManager
$httpUtils
protected
mixed
$httpUtils
$logger
protected
mixed
$logger
$options
protected
mixed
$options
$providerKey
protected
mixed
$providerKey
$dispatcher
private
mixed
$dispatcher
$failureHandler
private
mixed
$failureHandler
$rememberMeServices
private
mixed
$rememberMeServices
$sessionStrategy
private
mixed
$sessionStrategy
$successHandler
private
mixed
$successHandler
$tokenStorage
private
mixed
$tokenStorage
Methods
__construct()
public
__construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, string $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler[, array<string|int, mixed> $options = [] ][, LoggerInterface $logger = null ][, EventDispatcherInterface $dispatcher = null ]) : mixed
Parameters
- $tokenStorage : TokenStorageInterface
- $authenticationManager : AuthenticationManagerInterface
- $sessionStrategy : SessionAuthenticationStrategyInterface
- $httpUtils : HttpUtils
- $providerKey : string
- $successHandler : AuthenticationSuccessHandlerInterface
- $failureHandler : AuthenticationFailureHandlerInterface
- $options : array<string|int, mixed> = []
- $logger : LoggerInterface = null
- $dispatcher : EventDispatcherInterface = null
Tags
Return values
mixed —__invoke()
public
final __invoke(RequestEvent $event) : mixed
Parameters
- $event : RequestEvent
Return values
mixed —authenticate()
Handles form based authentication.
public
authenticate(RequestEvent $event) : mixed
Parameters
- $event : RequestEvent
Tags
Return values
mixed —setRememberMeServices()
Sets the RememberMeServices implementation to use.
public
setRememberMeServices(RememberMeServicesInterface $rememberMeServices) : mixed
Parameters
- $rememberMeServices : RememberMeServicesInterface
Return values
mixed —supports()
Tells whether the authenticate() method should be called or not depending on the incoming request.
public
supports(Request $request) : bool|null
Parameters
- $request : Request
Return values
bool|null —attemptAuthentication()
Performs authentication.
protected
abstract attemptAuthentication(Request $request) : TokenInterface|Response|null
Parameters
- $request : Request
Tags
Return values
TokenInterface|Response|null —The authenticated token, null if full authentication is not possible, or a Response
requiresAuthentication()
Whether this request requires authentication.
protected
requiresAuthentication(Request $request) : bool
The default implementation only processes requests to a specific path, but a subclass could change this to only authenticate requests where a certain parameters is present.
Parameters
- $request : Request
Return values
bool —onFailure()
private
onFailure(Request $request, AuthenticationException $failed) : Response
Parameters
- $request : Request
- $failed : AuthenticationException
Return values
Response —onSuccess()
private
onSuccess(Request $request, TokenInterface $token) : Response
Parameters
- $request : Request
- $token : TokenInterface