Symfony2 API
Class

Symfony\Component\Security\Http\RememberMe\PersistentTokenBasedRememberMeServices

class PersistentTokenBasedRememberMeServices extends AbstractRememberMeServices

Concrete implementation of the RememberMeServicesInterface which needs an implementation of TokenProviderInterface for providing remember-me capabilities.

Constants

COOKIE_DELIMITER

Methods

__construct(array $userProviders, string $key, string $providerKey, array $options = array(), LoggerInterface $logger = null, SecureRandomInterface $secureRandom)

Constructor.

string getRememberMeParameter()

Returns the parameter that is used for checking whether remember-me services have been requested.

from AbstractRememberMeServices
string getKey()

from AbstractRememberMeServices
TokenInterface|null autoLogin(Request $request)

This method will be called whenever the SecurityContext does not contain an TokenInterface object and the framework wishes to provide an implementation with an opportunity to authenticate the request using remember-me capabilities.

from AbstractRememberMeServices
logout(Request $request, Response $response, TokenInterface $token)

This method is called by the LogoutListener when a user has requested to be logged out.

from AbstractRememberMeServices
loginFail(Request $request)

Called whenever an interactive authentication attempt was made, but the credentials supplied by the user were missing or otherwise invalid.

from AbstractRememberMeServices
loginSuccess(Request $request, Response $response, TokenInterface $token)

Called whenever an interactive authentication attempt is successful (e.g.

from AbstractRememberMeServices
setTokenProvider(TokenProviderInterface $tokenProvider)

Sets the token provider.

Details

at line 47
public __construct(array $userProviders, string $key, string $providerKey, array $options = array(), LoggerInterface $logger = null, SecureRandomInterface $secureRandom)

Constructor.

Parameters

array $userProviders
string $key
string $providerKey
array $options
LoggerInterface $logger
SecureRandomInterface $secureRandom

public string getRememberMeParameter()

Returns the parameter that is used for checking whether remember-me services have been requested.

Return Value

string

public string getKey()

Return Value

string

final public TokenInterface|null autoLogin(Request $request)

This method will be called whenever the SecurityContext does not contain an TokenInterface object and the framework wishes to provide an implementation with an opportunity to authenticate the request using remember-me capabilities.

No attempt whatsoever is made to determine whether the browser has requested remember-me services or presented a valid cookie. Any and all such determinations are left to the implementation of this method.

If a browser has presented an unauthorised cookie for whatever reason, make sure to throw an AuthenticationException as this will consequentially result in a call to loginFail() and therefore an invalidation of the cookie.

Parameters

Request $request

Return Value

TokenInterface|null

public logout(Request $request, Response $response, TokenInterface $token)

This method is called by the LogoutListener when a user has requested to be logged out.

Usually, you would unset session variables, or remove cookies, etc.

Parameters

Request $request
Response $response
TokenInterface $token

final public loginFail(Request $request)

Called whenever an interactive authentication attempt was made, but the credentials supplied by the user were missing or otherwise invalid.

This method needs to take care of invalidating the cookie.

Parameters

Request $request

final public loginSuccess(Request $request, Response $response, TokenInterface $token)

Called whenever an interactive authentication attempt is successful (e.g.

a form login).

An implementation may always set a remember-me cookie in the Response, although this is not recommended.

Instead, implementations should typically look for a request parameter (such as a HTTP POST parameter) that indicates the browser has explicitly requested for the authentication to be remembered.

Parameters

Request $request
Response $response
TokenInterface $token The token that resulted in a successful authentication

at line 59
public setTokenProvider(TokenProviderInterface $tokenProvider)

Sets the token provider.

Parameters

TokenProviderInterface $tokenProvider