From 471e5bc21a88b75b1bb7769841fda7a65a142c51 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 5 May 2013 19:24:00 +0200 Subject: [PATCH] [Security] allowed simple pre-auth to be optional if another auth mechanism already authenticated the user --- .../Http/Firewall/SimplePreAuthenticationListener.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php index 80b35a55ac..2a6b4d5c0d 100644 --- a/src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php @@ -19,6 +19,7 @@ use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface; use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface; @@ -71,6 +72,10 @@ class SimplePreAuthenticationListener implements ListenerInterface $this->logger->info(sprintf('Attempting simple pre-authorization %s', $this->providerKey)); } + if (null !== $this->context->getToken() && !$this->context->getToken() instanceof AnonymousToken) { + return; + } + try { $token = $this->simpleAuthenticator->createToken($request, $this->providerKey); $token = $this->authenticationManager->authenticate($token);