diff --git a/src/Symfony/Component/Security/CHANGELOG.md b/src/Symfony/Component/Security/CHANGELOG.md index 2fc862f6e03a7..dfc7907b64cae 100644 --- a/src/Symfony/Component/Security/CHANGELOG.md +++ b/src/Symfony/Component/Security/CHANGELOG.md @@ -18,6 +18,7 @@ CHANGELOG * removed HTTP digest authentication * removed `GuardAuthenticatorInterface` in favor of `AuthenticatorInterface` * removed `AbstractGuardAuthenticator::supports()` + * added target user to `SwitchUserListener` 3.4.0 ----- diff --git a/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php b/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php index 548ce7ce91900..c8cca7ea10f0b 100644 --- a/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php @@ -126,7 +126,9 @@ private function attemptSwitchUser(Request $request, $username) throw new \LogicException(sprintf('You are already switched to "%s" user.', $token->getUsername())); } - if (false === $this->accessDecisionManager->decide($token, array($this->role))) { + $user = $this->provider->loadUserByUsername($username); + + if (false === $this->accessDecisionManager->decide($token, array($this->role), $user)) { $exception = new AccessDeniedException(); $exception->setAttributes($this->role); @@ -137,7 +139,6 @@ private function attemptSwitchUser(Request $request, $username) $this->logger->info('Attempting to switch to user.', array('username' => $username)); } - $user = $this->provider->loadUserByUsername($username); $this->userChecker->checkPostAuth($user); $roles = $user->getRoles(); diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php index 0e61ee208ee2c..bdab1f24d58eb 100644 --- a/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php +++ b/src/Symfony/Component/Security/Http/Tests/Firewall/SwitchUserListenerTest.php @@ -182,7 +182,7 @@ public function testSwitchUser() $this->request->query->set('_switch_user', 'kuba'); $this->accessDecisionManager->expects($this->once()) - ->method('decide')->with($token, array('ROLE_ALLOWED_TO_SWITCH')) + ->method('decide')->with($token, array('ROLE_ALLOWED_TO_SWITCH'), $user) ->will($this->returnValue(true)); $this->userProvider->expects($this->once()) @@ -212,7 +212,7 @@ public function testSwitchUserKeepsOtherQueryStringParameters() )); $this->accessDecisionManager->expects($this->once()) - ->method('decide')->with($token, array('ROLE_ALLOWED_TO_SWITCH')) + ->method('decide')->with($token, array('ROLE_ALLOWED_TO_SWITCH'), $user) ->will($this->returnValue(true)); $this->userProvider->expects($this->once()) @@ -240,7 +240,7 @@ public function testSwitchUserWithReplacedToken() $this->request->query->set('_switch_user', 'kuba'); $this->accessDecisionManager->expects($this->any()) - ->method('decide')->with($token, array('ROLE_ALLOWED_TO_SWITCH')) + ->method('decide')->with($token, array('ROLE_ALLOWED_TO_SWITCH'), $user) ->will($this->returnValue(true)); $this->userProvider->expects($this->any()) @@ -276,7 +276,7 @@ public function testSwitchUserStateless() $this->request->query->set('_switch_user', 'kuba'); $this->accessDecisionManager->expects($this->once()) - ->method('decide')->with($token, array('ROLE_ALLOWED_TO_SWITCH')) + ->method('decide')->with($token, array('ROLE_ALLOWED_TO_SWITCH'), $user) ->will($this->returnValue(true)); $this->userProvider->expects($this->once()) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy