From bb138dadb3ad5a0b5850fc25bd2f9ec8d47880ed Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 6 Jul 2012 23:57:26 +0200 Subject: [PATCH] [Security] Fix regression after rebase. Target url should be firewall dependent --- .../Security/Factory/AbstractFactory.php | 9 +++++---- .../Resources/config/security_listeners.xml | 1 + .../DefaultAuthenticationSuccessHandler.php | 11 +++++++---- .../UsernamePasswordFormAuthenticationListener.php | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php index eae720e52d..210252f69b 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/AbstractFactory.php @@ -172,12 +172,13 @@ abstract class AbstractFactory implements SecurityFactoryInterface return $config['success_handler']; } - $id = 'security.authentication.success_handler.'.$id; + $successHandlerId = 'security.authentication.success_handler.'.$id; - $successHandler = $container->setDefinition($id, new DefinitionDecorator('security.authentication.success_handler')); - $successHandler->replaceArgument(1, array_intersect_key($config, $this->defaultSuccessHandlerOptions)); + $successHandler = $container->setDefinition($successHandlerId, new DefinitionDecorator('security.authentication.success_handler')); + $successHandler->replaceArgument(1, $id); + $successHandler->replaceArgument(2, array_intersect_key($config, $this->defaultSuccessHandlerOptions)); - return $id; + return $successHandlerId; } protected function createAuthenticationFailureHandler($container, $id, $config) diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml index a0d01a33d1..6c39faceff 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml @@ -111,6 +111,7 @@ + diff --git a/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php b/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php index 88dcf68080..deb7d4574a 100644 --- a/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php +++ b/src/Symfony/Component/Security/Http/Authentication/DefaultAuthenticationSuccessHandler.php @@ -29,16 +29,19 @@ class DefaultAuthenticationSuccessHandler implements AuthenticationSuccessHandle { protected $httpUtils; protected $options; + protected $providerKey; /** * Constructor. * * @param HttpUtils $httpUtils + * @param string $providerKey * @param array $options Options for processing a successful authentication attempt. */ - public function __construct(HttpUtils $httpUtils, array $options) + public function __construct(HttpUtils $httpUtils, $providerKey, array $options) { - $this->httpUtils = $httpUtils; + $this->httpUtils = $httpUtils; + $this->providerKey = $providerKey; $this->options = array_merge(array( 'always_use_default_target_path' => false, @@ -75,8 +78,8 @@ class DefaultAuthenticationSuccessHandler implements AuthenticationSuccessHandle } $session = $request->getSession(); - if ($targetUrl = $session->get('_security.target_path')) { - $session->remove('_security.target_path'); + if ($targetUrl = $session->get('_security.'.$this->providerKey.'.target_path')) { + $session->remove('_security.'.$this->providerKey.'.target_path'); return $targetUrl; } diff --git a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php index 87a4cf6ec5..22330a8c43 100644 --- a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php @@ -37,7 +37,7 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL /** * {@inheritdoc} */ - public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler = null, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, CsrfProviderInterface $csrfProvider = null) + public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $providerKey, AuthenticationSuccessHandlerInterface $successHandler, AuthenticationFailureHandlerInterface $failureHandler, array $options = array(), LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, CsrfProviderInterface $csrfProvider = null) { parent::__construct($securityContext, $authenticationManager, $sessionStrategy, $httpUtils, $providerKey, $successHandler, $failureHandler, array_merge(array( 'username_parameter' => '_username',