https://github.com/imankarimi/django-auth-protection
Django Auth Protection This package logout users from the system by changing the password in Simple JWT REST API.
https://github.com/imankarimi/django-auth-protection
authentication django django-rest-framework jwt simple-jwt
Last synced: 3 months ago
JSON representation
Django Auth Protection This package logout users from the system by changing the password in Simple JWT REST API.
- Host: GitHub
- URL: https://github.com/imankarimi/django-auth-protection
- Owner: imankarimi
- License: mit
- Created: 2022-04-16T10:53:05.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-01T10:55:42.000Z (about 4 years ago)
- Last Synced: 2025-09-27T17:16:21.328Z (9 months ago)
- Topics: authentication, django, django-rest-framework, jwt, simple-jwt
- Language: Python
- Homepage: https://github.com/imankarimi/django-auth-protection
- Size: 10.7 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Django Auth Protection
**Django Auth Protection** This package logout users from the system by changing the password in REST API.
## Why Django Auth Protection?
Simple JWT provides a JSON Web Token authentication backend for the Django REST Framework. It aims to cover the most common use cases of JWTs by offering a conservative set of default features. It also aims to be easily extensible in case a desired feature is not present. But one of the problems is that when the users change the password, they can continue to work on the system with the previous token until it expires. This package overrides the Simple JWT to solve this problem.
## How to use it
* Download and install latest version of Django Auth Protection:
```bash
$ pip install django-auth-protection
# or
$ easy_install django-auth-protection
```
Then you have to create a custom `TokenObtainPairView` class and change the `serializer_class` to `ProtectTokenObtainPairSerializer` (follow the sample):
- Make a custom `TokenObtainPairView` and change the `serializer_class`:
```python
from auth_protection.serializers import ProtectTokenObtainPairSerializer
class CustomTokenObtainPairView(TokenObtainPairView):
serializer_class = ProtectTokenObtainPairSerializer
```
- Change All `authentication_classes` on your views and replace it with `JWTAuthProtection`:
```python
from auth_protection.authentications import JWTAuthProtection
class SampleView(TARGET_VIEW):
authentication_classes = [JWTAuthProtection]
```
- Change your `TokenRefreshView` view to `ProtectTokenRefreshView` (EX: `urls.py`):
```python
from auth_protection.views import ProtectTokenRefreshView
urlpatterns = [
# ...
path('YOUR_PATH/refresh/', ProtectTokenRefreshView.as_view(), name='URL_NAME'),
# ...
]
```