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

Allow None for JTI_CLAIM and TOKEN_TYPE_CLAIM #489

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions rest_framework_simplejwt/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,14 @@ def verify(self):
self.check_exp()

# Ensure token id is present
if api_settings.JTI_CLAIM not in self.payload:
if (
api_settings.JTI_CLAIM is not None
and api_settings.JTI_CLAIM not in self.payload
):
raise TokenError(_('Token has no id'))

self.verify_token_type()
if api_settings.TOKEN_TYPE_CLAIM is not None:
self.verify_token_type()
Comment on lines +102 to +103
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first this seemed strange, but I remembered it's Auth0. If possible, please leave a comment mentioning how this should only apply to outside services. Customization of tokens should still stride to use the TOKEN_TYPE_CLAIM setting. A test case would be great!


def verify_token_type(self):
"""
Expand Down Expand Up @@ -181,9 +185,9 @@ def for_user(cls, user):
token[api_settings.USER_ID_CLAIM] = user_id

return token

_token_backend = None

def get_token_backend(self):
if self._token_backend is None:
self._token_backend = import_string(
Expand Down