Skip to content

Commit

Permalink
[Security] Do not save the target path in the session for a stateless…
Browse files Browse the repository at this point in the history
… firewall
  • Loading branch information
lyrixx authored and fabpot committed Jul 26, 2015
1 parent f1ebfd7 commit 3358253
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Expand Up @@ -349,7 +349,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
$listeners[] = new Reference('security.access_listener');

// Exception listener
$exceptionListener = new Reference($this->createExceptionListener($container, $firewall, $id, $configuredEntryPoint ?: $defaultEntryPoint));
$exceptionListener = new Reference($this->createExceptionListener($container, $firewall, $id, $configuredEntryPoint ?: $defaultEntryPoint, $firewall['stateless']));

return array($matcher, $listeners, $exceptionListener);
}
Expand Down Expand Up @@ -534,12 +534,13 @@ private function getUserProviderId($name)
return 'security.user.provider.concrete.'.$name;
}

private function createExceptionListener($container, $config, $id, $defaultEntryPoint)
private function createExceptionListener($container, $config, $id, $defaultEntryPoint, $stateless)
{
$exceptionListenerId = 'security.exception_listener.'.$id;
$listener = $container->setDefinition($exceptionListenerId, new DefinitionDecorator('security.exception_listener'));
$listener->replaceArgument(3, $id);
$listener->replaceArgument(4, null === $defaultEntryPoint ? null : new Reference($defaultEntryPoint));
$listener->replaceArgument(8, $stateless);

// access denied handler setup
if (isset($config['access_denied_handler'])) {
Expand Down
Expand Up @@ -186,6 +186,7 @@
<argument>%security.access.denied_url%</argument>
<argument type="service" id="security.access.denied_handler" on-invalid="null" />
<argument type="service" id="logger" on-invalid="null" />
<argument>false</argument> <!-- Stateless -->
</service>

<service id="security.authentication.switchuser_listener" class="%security.authentication.switchuser_listener.class%" public="false" abstract="true">
Expand Down
Expand Up @@ -46,8 +46,9 @@ class ExceptionListener
private $errorPage;
private $logger;
private $httpUtils;
private $stateless;

public function __construct(SecurityContextInterface $context, AuthenticationTrustResolverInterface $trustResolver, HttpUtils $httpUtils, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null, LoggerInterface $logger = null)
public function __construct(SecurityContextInterface $context, AuthenticationTrustResolverInterface $trustResolver, HttpUtils $httpUtils, $providerKey, AuthenticationEntryPointInterface $authenticationEntryPoint = null, $errorPage = null, AccessDeniedHandlerInterface $accessDeniedHandler = null, LoggerInterface $logger = null, $stateless = false)
{
$this->context = $context;
$this->accessDeniedHandler = $accessDeniedHandler;
Expand All @@ -57,6 +58,7 @@ public function __construct(SecurityContextInterface $context, AuthenticationTru
$this->authenticationTrustResolver = $trustResolver;
$this->errorPage = $errorPage;
$this->logger = $logger;
$this->stateless = $stateless;
}

/**
Expand Down Expand Up @@ -178,7 +180,9 @@ private function startAuthentication(Request $request, AuthenticationException $
$this->logger->debug('Calling Authentication entry point');
}

$this->setTargetPath($request);
if (!$this->stateless) {
$this->setTargetPath($request);
}

if ($authException instanceof AccountStatusException) {
// remove the security token to prevent infinite redirect loops
Expand Down

0 comments on commit 3358253

Please sign in to comment.