interface InteractiveAuthenticatorInterface implementsAuthenticatorInterface

This is an extension of the authenticator interface that may be used by interactive authenticators.

Interactive login requires explicit user action (e.g. a login form). Implementing this interface will dispatch the InteractiveLoginEvent upon successful login.

Methods

bool|null
supports(Request$request)

Does the authenticator support the given Request?

Passport
authenticate(Request$request)

Create a passport for the current request.

createToken(Passport$passport,string$firewallName)

Create an authenticated token for the given user.

Response|null
onAuthenticationSuccess(Request$request,TokenInterface$token,string$firewallName)

Called when authentication executed and was successful!

Response|null
onAuthenticationFailure(Request$request,AuthenticationException$exception)

Called when authentication executed, but failed (e.g. wrong username password).

bool
isInteractive()

Should return true to make this authenticator perform an interactive login.

Details

bool|null supports(Request$request)

Does the authenticator support the given Request?

If this returns true, authenticate() will be called. If false, the authenticator will be skipped.

Returning null means authenticate() can be called lazily when accessing the token storage.

Parameters

Request $request

Return Value

bool|null

Passport authenticate(Request$request)

Create a passport for the current request.

The passport contains the user, credentials and any additional information that has to be checked by the Symfony Security system. For example, a login form authenticator will probably return a passport containing the user, the presented password and the CSRF token value.

You may throw any AuthenticationException in this method in case of error (e.g. a UserNotFoundException when the user cannot be found).

Parameters

Request $request

Return Value

Passport

Exceptions

AuthenticationException

TokenInterface createToken(Passport$passport,string$firewallName)

Create an authenticated token for the given user.

If you don't care about which token class is used or don't really understand what a "token" is, you can skip this method by extending the AbstractAuthenticator class from your authenticator.

Parameters

Passport $passport
string $firewallName

Return Value

TokenInterface

See also

AbstractAuthenticator

Response|null onAuthenticationSuccess(Request$request,TokenInterface$token,string$firewallName)

Called when authentication executed and was successful!

This should return the Response sent back to the user, like a RedirectResponse to the last page they visited.

If you return null, the current request will continue, and the user will be authenticated. This makes sense, for example, with an API.

Parameters

Request $request
TokenInterface $token
string $firewallName

Return Value

Response|null

Response|null onAuthenticationFailure(Request$request,AuthenticationException$exception)

Called when authentication executed, but failed (e.g. wrong username password).

This should return the Response sent back to the user, like a RedirectResponse to the login page or a 403 response.

If you return null, the request will continue, but the user will not be authenticated. This is probably not what you want to do.

Parameters

Request $request
AuthenticationException $exception

Return Value

Response|null

bool isInteractive()

Should return true to make this authenticator perform an interactive login.

Return Value

bool