-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
SecurityhasPRA Pull Request has already been submitted for this issue.A Pull Request has already been submitted for this issue.
Description
Here it says:
"The firewall dispatches the security.switch_user
event right after the impersonation is completed."
In the file vendor/symfony/security-http/SecurityEvents.php you can find this:
"The SWITCH_USER
event occurs before switch to another user..."
If you look at the code below it seems to me like the user is not switched, because in the service it returns PostAuthenticationToken
and I expected it to return SwitchUserToken
.
public function onSwitchUser(SwitchUserEvent $event): void
{
$token = $event->getToken(); dump($token); // This returns SwitchUserToken
...
.... later ....
$this->someService->someMethod();
}
The called method:
public function someMethod()
{
$token = $this->security->getToken(); dump($token); // This returns PostAuthenticationToken
if ($token instanceof SwitchUserToken)
{
$impersonatorUser = $token->getOriginalToken()->getUser();
......
}
}
And, then when I visit another page which also uses someMethod
, it returns SwitchUserToken
as expected.
Metadata
Metadata
Assignees
Labels
SecurityhasPRA Pull Request has already been submitted for this issue.A Pull Request has already been submitted for this issue.