Skip to content

Commit c301471

Browse files
committed
bug #21136 [Security] use authenticated token for json authentication (fbourigault)
This PR was merged into the 3.3-dev branch. Discussion ---------- [Security] use authenticated token for json authentication | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #21123 | License | MIT | Doc PR | N/A When using `UsernamePasswordJsonAuthenticationListener` with [LexikJWTAuthenticationBundle](https://github.com/lexik/LexikJWTAuthenticationBundle), we get a type exception > Type error: Argument 1 passed to Lexik\Bundle\JWTAuthenticationBundle\Security\Http\Authentication\AuthenticationSuccessHandler::handleAuthenticationSuccess() must implement interface Symfony\Component\Security\Core\User\UserInterface, string given, called in .../vendor/lexik/jwt-authentication-bundle/Security/Http/Authentication/AuthenticationSuccessHandler.php on line 47 This error occurs because the `UsernamePasswordJsonAuthenticationListener` send to the authentication success handler the token which have the user as a string and not the authenticated one that have a UserInterface as user. Commits ------- 208c617716 use authenticated token for json authentication
2 parents 6696476 + b8d6e69 commit c301471

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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
}

0 commit comments

Comments
 (0)