diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml index 64a2c251de..63f4b48c73 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml @@ -58,8 +58,8 @@ - + diff --git a/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php index 986c9a8ee1..72f0071424 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php @@ -31,7 +31,7 @@ class AnonymousAuthenticationListener implements ListenerInterface private $authenticationManager; private $logger; - public function __construct(SecurityContextInterface $context, $key, AuthenticationManagerInterface $authenticationManager, LoggerInterface $logger = null) + public function __construct(SecurityContextInterface $context, $key, LoggerInterface $logger = null, AuthenticationManagerInterface $authenticationManager = null) { $this->context = $context; $this->key = $key; @@ -51,7 +51,10 @@ class AnonymousAuthenticationListener implements ListenerInterface } try { - $token = $this->authenticationManager->authenticate(new AnonymousToken($this->key, 'anon.', array())); + if (null !== $this->authenticationManager) { + $token = $this->authenticationManager->authenticate(new AnonymousToken($this->key, 'anon.', array())); + } + $this->context->setToken($token); if (null !== $this->logger) {