-
-
Notifications
You must be signed in to change notification settings - Fork 611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JWTManager uses undefined function "getCredentials" of class "Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken" #1040
Comments
Hi, I just got hit by this bug. The failure is caused by It works when called with a Unfortunately, no interface is defined to easily check the provided token is compatible with The only solution on your side is to check the method exists on the token before trying to decode it: if (!\is_object($token) || !method_exists($token, "getCredentials")) {
throw new \Exception("Not a jwt token");
}
$payload = $jwtManager->decode($token);
if ($payload === false) {
throw new \Exception("Invalid jwt token");
} Are you guys open to a PR adding a |
Hi, sorry about the super late reply. but I'd need some reproducing code in order to understand the issue and eventually fix it. Please comment if you can provide that. |
Hi @chalasr , Can you tell us why this issue is closed, please? The offending code is unchanged in v3 branch and v2 branch. And, as far as I can see, \Symfony\Component\Security\Core\Authentication\Token\TokenInterface still has no Running phpstan on
Can you provide a link to the PR fixing the issue so I can review it? |
I closed the issue due to the lack of reply from the OP and more precisely the lack of reproducing code. |
By a reproducer code, you mean something like this? $token = new NullToken();
$this->jwtManager->decode($token); Any class inheriting from As I stated, you don't even need a reproducer code. You might simply want to fix the error reported by phpstan on It is hard for me to propose a PR as I don't even know what would be an acceptable solution. I suggested three possibilities in my previous message. |
Same issue
|
PR welcome 🙏 |
The PR is here: #1244 |
Hi guys!
I'm using symfony 6 (after i upgrade from version 5.3) , I installed the bundle lexikJWTAuthenticationBundle, now i intent to decode the created token so i refere to this documentation:
https://symfony.com/bundles/LexikJWTAuthenticationBundle/current/9-access-authenticated-jwt-token.html
I got this error when i use this code to decode the generated token
Attempted to call an undefined method named "getCredentials" of class "Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken"
I suppose that the decode function in Lexik\Bundle\JWTAuthenticationBundle\Services\JWTManager uses the function getCredentials that is deprecated in symfony 5.4 and removed in symfony 6.
I will appreciate any help! thanks in advance.
The text was updated successfully, but these errors were encountered: