Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 27fdeef

Browse files
Fabien Bourigaultfbourigault
authored andcommitted
use authenticated token for json authentication
1 parent 90bb3ea commit 27fdeef

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Http/Firewall/UsernamePasswordJsonAuthenticationListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ public function handle(GetResponseEvent $event)
101101
try {
102102
$token = new UsernamePasswordToken($username, $password, $this->providerKey);
103103

104-
$this->authenticationManager->authenticate($token);
105-
$response = $this->onSuccess($request, $token);
104+
$authenticatedToken = $this->authenticationManager->authenticate($token);
105+
$response = $this->onSuccess($request, $authenticatedToken);
106106
} catch (AuthenticationException $e) {
107107
$response = $this->onFailure($request, $e);
108108
}

Tests/Http/Firewall/UsernamePasswordJsonAuthenticationListenerTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\HttpKernel\KernelInterface;
1818
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
1919
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
20+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
2021
use Symfony\Component\Security\Core\Exception\AuthenticationException;
2122
use Symfony\Component\Security\Core\Security;
2223
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
@@ -38,8 +39,10 @@ private function createListener(array $options = array(), $success = true)
3839
$tokenStorage = $this->getMockBuilder(TokenStorageInterface::class)->getMock();
3940
$authenticationManager = $this->getMockBuilder(AuthenticationManagerInterface::class)->getMock();
4041

42+
$authenticatedToken = $this->getMockBuilder(TokenInterface::class)->getMock();
43+
4144
if ($success) {
42-
$authenticationManager->method('authenticate')->willReturn(true);
45+
$authenticationManager->method('authenticate')->willReturn($authenticatedToken);
4346
} else {
4447
$authenticationManager->method('authenticate')->willThrowException(new AuthenticationException());
4548
}

0 commit comments

Comments
 (0)