8000 Fixed being logged out on failed attempt in guard · symfony/symfony@4fc0ecb · GitHub
[go: up one dir, main page]

Skip to content

Commit 4fc0ecb

Browse files
author
Iltar van der Berg
committed
Fixed being logged out on failed attempt in guard
1 parent 49b94cc commit 4fc0ecb

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1919
use Symfony\Component\Security\Core\Exception\AuthenticationException;
2020
use Symfony\Component\Security\Core\User\UserInterface;
21-
use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken;
2221
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
2322
use Symfony\Component\Security\Http\SecurityEvents;
2423

@@ -116,11 +115,6 @@ public function authenticateUserAndHandleSuccess(UserInterface $user, Request $r
116115
*/
117116
public function handleAuthenticationFailure(AuthenticationException $authenticationException, Request $request, GuardAuthenticatorInterface $guardAuthenticator, $providerKey)
118117
{
119-
$token = $this->tokenStorage->getToken();
120-
if ($token instanceof PostAuthenticationGuardToken && $providerKey === $token->getProviderKey()) {
121-
$this->tokenStorage->setToken(null);
122-
}
123-
124118
$response = $guardAuthenticator->onAuthenticationFailure($request, $authenticationException);
125119
if ($response instanceof Response || null === $response) {
126120
// returning null is ok, it means they want the request to continue

src/Symfony/Component/Security/Guard/Tests/GuardAuthenticatorHandlerTest.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function testHandleAuthenticationFailure()
8181
/**
8282
* @dataProvider getTokenClearingTests
8383
*/
84-
public function testHandleAuthenticationClearsToken($tokenClass, $tokenProviderKey, $actualProviderKey, $shouldTokenBeCleared)
84+
public function testHandleAuthenticationClearsToken($tokenClass, $tokenProviderKey, $actualProviderKey)
8585
{
8686
$token = $this->getMockBuilder($tokenClass)
8787
->disableOriginalConstructor()
@@ -90,12 +90,7 @@ public function testHandleAuthenticationClearsToken($tokenClass, $tokenProviderK
9090
->method('getProviderKey')
9191
->will($this->returnValue($tokenProviderKey));
9292

93-
// make the $token be the current token
94-
$this->tokenStorage->expects($this->once())
95-
->method('getToken')
96-
->will($this->returnValue($token));
97-
98-
$this->tokenStorage->expects($shouldTokenBeCleared ? $this->once() : $this->never())
93+
$this->tokenStorage->expects($this->never())
9994
->method('setToken')
10095
->with(null);
10196
$authException = new AuthenticationException('Bad password!');
@@ -115,9 +110,9 @@ public function getTokenClearingTests()
115110
{
116111
$tests = array();
117112
// correct token class and matching firewall => clear the token
118-
$tests[] = array('Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken', 'the_firewall_key', 'the_firewall_key', true);
119-
$tests[] = array('Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken', 'the_firewall_key', 'different_key', false);
120-
$tests[] = array('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', 'the_firewall_key', 'the_firewall_key', false);
113+
$tests[] = array('Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken', 'the_firewall_key', 'the_firewall_key');
114+
$tests[] = array('Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken', 'the_firewall_key', 'different_key');
115+
$tests[] = array('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', 'the_firewall_key', 'the_firewall_key');
121116

122117
return $tests;
123118
}

0 commit comments

Comments
 (0)
0