mediatekformation

SwitchUserListener extends AbstractListener
in package
implements ListenerInterface Uses LegacyListenerTrait

SwitchUserListener allows a user to impersonate another one temporarily (like the Unix su command).

Tags
author

Fabien Potencier fabien@symfony.com

final

since Symfony 4.3

Interfaces, Classes, Traits and Enums

ListenerInterface
Interface that must be implemented by firewall listeners.

Table of Contents

EXIT_VALUE  = '_exit'
$accessDecisionManager  : mixed
$dispatcher  : mixed
$logger  : mixed
$provider  : mixed
$providerKey  : mixed
$role  : mixed
$stateless  : mixed
$tokenStorage  : mixed
$userChecker  : mixed
$usernameParameter  : mixed
__construct()  : mixed
__invoke()  : mixed
authenticate()  : mixed
Handles the switch to another user.
supports()  : bool|null
Tells whether the authenticate() method should be called or not depending on the incoming request.
attemptExitUser()  : TokenInterface
Attempts to exit from an already switched user and returns the original token.
attemptSwitchUser()  : TokenInterface|null
Attempts to switch to another user and returns the new token if successfully switched.
getOriginalToken()  : TokenInterface|null

Constants

Properties

Methods

__construct()

public __construct(TokenStorageInterface $tokenStorage, UserProviderInterface $provider, UserCheckerInterface $userChecker, string $providerKey, AccessDecisionManagerInterface $accessDecisionManager[, LoggerInterface $logger = null ][, string $usernameParameter = '_switch_user' ][, string $role = 'ROLE_ALLOWED_TO_SWITCH' ][, EventDispatcherInterface $dispatcher = null ][, bool $stateless = false ]) : mixed
Parameters
$tokenStorage : TokenStorageInterface
$provider : UserProviderInterface
$userChecker : UserCheckerInterface
$providerKey : string
$accessDecisionManager : AccessDecisionManagerInterface
$logger : LoggerInterface = null
$usernameParameter : string = '_switch_user'
$role : string = 'ROLE_ALLOWED_TO_SWITCH'
$dispatcher : EventDispatcherInterface = null
$stateless : bool = false
Return values
mixed

authenticate()

Handles the switch to another user.

public authenticate(RequestEvent $event) : mixed
Parameters
$event : RequestEvent
Tags
throws
LogicException

if switching to a user failed

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

attemptSwitchUser()

Attempts to switch to another user and returns the new token if successfully switched.

private attemptSwitchUser(Request $request, string $username) : TokenInterface|null
Parameters
$request : Request
$username : string
Tags
throws
LogicException
throws
AccessDeniedException
Return values
TokenInterface|null

Search results