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

Token stored in OutstandingToken and actual token are different when token payload is modified. #717

Open
ss-bhat opened this issue Jun 18, 2023 · 2 comments

Comments

@ss-bhat
Copy link

ss-bhat commented Jun 18, 2023

The simple JWT document says we can customize token claims from TokenObtainPairSerializer -> get_token class method.

However, if we customize the token according to the above document and enable the blacklist app, the token stored in the OutstandingToken model is different. Because the BlacklistMixin -> for_user is executed before modifying the token.

If the tokens are different, it will be difficult in identifying the token while blacklisting.

Reference:

OutstandingToken.objects.create(
user=user,
jti=jti,
token=str(token),
created_at=token.current_time,
expires_at=datetime_from_epoch(exp),
)

@sevdog
Copy link

sevdog commented May 20, 2024

To be more specific: it would be very bad if the JTI claim is changed after the for_user method has been called since that claim is used to identify tokens

if BlacklistedToken.objects.filter(token__jti=jti).exists():
raise TokenError(_("Token is blacklisted"))

@roshi112
Copy link

Any solution for that ?? facing the same issue.

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

No branches or pull requests

3 participants