W3cubDocs

/Symfony 4.1

UserAuthenticationProvider

abstract class UserAuthenticationProvider implements AuthenticationProviderInterface

UserProviderInterface retrieves users for UsernamePasswordToken tokens.

Methods

__construct(UserCheckerInterface $userChecker, string $providerKey, bool $hideUserNotFoundExceptions = true)
TokenInterface authenticate(TokenInterface $token)

Attempts to authenticate a TokenInterface object.

bool supports(TokenInterface $token)

Checks whether this provider supports the given token.

UserInterface retrieveUser(string $username, UsernamePasswordToken $token)

Retrieves the user from an implementation-specific location.

checkAuthentication(UserInterface $user, UsernamePasswordToken $token)

Does additional checks on the user and token (like validating the credentials).

Details

__construct(UserCheckerInterface $userChecker, string $providerKey, bool $hideUserNotFoundExceptions = true)

Parameters

UserCheckerInterface $userChecker
string $providerKey
bool $hideUserNotFoundExceptions

Exceptions

InvalidArgumentException

TokenInterface authenticate(TokenInterface $token)

Attempts to authenticate a TokenInterface object.

Parameters

TokenInterface $token The TokenInterface instance to authenticate

Return Value

TokenInterface An authenticated TokenInterface instance, never null

Exceptions

AuthenticationException if the authentication fails

bool supports(TokenInterface $token)

Checks whether this provider supports the given token.

Parameters

TokenInterface $token

Return Value

bool true if the implementation supports the Token, false otherwise

abstract protected UserInterface retrieveUser(string $username, UsernamePasswordToken $token)

Retrieves the user from an implementation-specific location.

Parameters

string $username The username to retrieve
UsernamePasswordToken $token The Token

Return Value

UserInterface The user

Exceptions

AuthenticationException if the credentials could not be validated

abstract protected checkAuthentication(UserInterface $user, UsernamePasswordToken $token)

Does additional checks on the user and token (like validating the credentials).

Parameters

UserInterface $user
UsernamePasswordToken $token

Exceptions

AuthenticationException if the credentials could not be validated