sunscrapers / djoser

REST implementation of Django authentication system.
MIT License
2.55k stars 458 forks source link

Chore: Add TokenBlacklistView to JWT URLs #839

Open CHIHCHIEH-LAI opened 3 months ago

CHIHCHIEH-LAI commented 3 months ago

This pull request adds support for blacklisting JWT refresh tokens in the Djoser authentication package, which integrates with Django Rest Framework's SimpleJWT package.

By default, Djoser supports JWT token obtain and refresh functionalities. However, in certain scenarios, it is necessary to invalidate refresh tokens. To address this, I have added a new URL pattern to support the blacklisting of refresh tokens:

re_path(r"^jwt/blacklist/?", views.TokenBlacklistView.as_view(), name="jwt-blacklist"),

Changes: Added TokenBlacklistView to JWT URLs to handle refresh token blacklisting.

Documentation: To ensure proper functionality, it is essential to update the documentation to include the following addition to the INSTALLED_APPS setting in Django:

INSTALLED_APPS = (
    ...
    'rest_framework_simplejwt.token_blacklist',
    ...
)