Skip to content

Commit 471e5bc

Browse files
fabpotSeldaek
authored andcommitted
[Security] allowed simple pre-auth to be optional if another auth mechanism already authenticated the user
1 parent 01c913b commit 471e5bc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Symfony/Component/Security/Http/Firewall/SimplePreAuthenticationListener.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\HttpFoundation\Response;
2020
use Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface;
2121
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
22+
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
2223
use Symfony\Component\Security\Core\Exception\AuthenticationException;
2324
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
2425
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
@@ -71,6 +72,10 @@ public function handle(GetResponseEvent $event)
7172
$this->logger->info(sprintf('Attempting simple pre-authorization %s', $this->providerKey));
7273
}
7374

75+
if (null !== $this->context->getToken() && !$this->context->getToken() instanceof AnonymousToken) {
76+
return;
77+
}
78+
7479
try {
7580
$token = $this->simpleAuthenticator->createToken($request, $this->providerKey);
7681
$token = $this->authenticationManager->authenticate($token);

0 commit comments

Comments
 (0)