Skip to content
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

"Invalid JWT Token" when using decode from JWTTokenManagerInterface #921

Closed
fd6130 opened this issue Sep 16, 2021 · 1 comment · Fixed by #922
Closed

"Invalid JWT Token" when using decode from JWTTokenManagerInterface #921

fd6130 opened this issue Sep 16, 2021 · 1 comment · Fixed by #922

Comments

@fd6130
Copy link

fd6130 commented Sep 16, 2021

Symfony version: 5.3
Bundle version: 2.13.0

When i try to follow this PR #604 to decode the token $jwtManager->decode($token->getToken()); it throw exception "Invalid JWT Token" .

The culprit is $token->getCredentials(), it is empty even though i already login.

    // class JWTManager
    public function decode(TokenInterface $token)
    {
        if (!($payload = $this->jwtEncoder->decode($token->getCredentials()))) {
            return false;
        }

        // ...
    }
@fd6130
Copy link
Author

fd6130 commented Sep 16, 2021

update

Ok my guessing is that due to the support of new authentication system in this bundle, the JWTAuthenticator use PostAuthenticationToken that have no credentials included.

My proposal to fix this issue is that include the jwt token by setting attribute for the SelfValidatingPassport then use JWTPostAuthenticationToken (which haven't implement) instead of The PostAuthenticationToken in JWTAuthenticator. That should solve the issue when calling $jwtManager->decode($token->getToken());

I can make a PR for this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant