Installation
Download and install latest version of Django Auth Protection:
$ pip install django-auth-protection
How to use it
Then you have to create a custom TokenObtainPairView class and change the serializer_class to ProtectTokenObtainPairSerializer (follow the sample):
Make a custom
TokenObtainPairViewand change theserializer_class:
from auth_protection.serializers import ProtectTokenObtainPairSerializer
class CustomTokenObtainPairView(TokenObtainPairView):
serializer_class = ProtectTokenObtainPairSerializer
Change All
authentication_classeson your views and replace it withJWTAuthProtection:
from auth_protection.authentications import JWTAuthProtection
class SampleView(TARGET_VIEW):
authentication_classes = [JWTAuthProtection]
Change your
TokenRefreshViewview toProtectTokenRefreshView(EX:urls.py):
from auth_protection.views import ProtectTokenRefreshView
urlpatterns = [
# ...
path('YOUR_PATH/refresh/', ProtectTokenRefreshView.as_view(), name='URL_NAME'),
# ...
]