Django REST Token Expiry is a Python package designed to add token expiration functionality to Django REST Framework's default token authentication system. This package allows developers to set expiry durations for authentication tokens, enhancing security by automatically invalidating tokens after a specified period.
Project description
Django REST Token Expiry
Django REST Token Expiry is a Python package designed to add token expiration functionality to Django REST Framework's default token authentication system. This package allows developers to set expiry durations for authentication tokens, enhancing security by automatically invalidating tokens after a specified period. Installation
You can install Django REST Token Expiry via pip:
pip install django-rest-token-expiry
Usage
Define AUTHENTICATION_TOKEN_EXPIRY
in your settings.py
with the desired time delta value for token expiration:
from datetime import timedelta
AUTHENTICATION_TOKEN_EXPIRY = timedelta(days=7) # Example: Token expires in 7 days
Update the DEFAULT_AUTHENTICATION_CLASSES
setting in your REST_FRAMEWORK
settings to include ExpiringTokenAuthentication
:
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
'django_rest_token_expiry.authentication.ExpiringTokenAuthentication' # ... other authentication classes
]
}
Now, the authentication tokens generated by Django REST Framework will have expiration based on the duration specified in AUTHENTICATION_TOKEN_EXPIRY
.
Contributing
Contributions are welcome! If you'd like to contribute to this project, please fork the repository and submit a pull request with your changes. License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_rest_token_expiry-1.0.tar.gz
.
File metadata
- Download URL: django_rest_token_expiry-1.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb6ebcc78b9ddfadfc381b4af6290fb9273ae183df1c5dc987674a5a84320376 |
|
MD5 | 79717a7fa120605c0b43ec9f733ae838 |
|
BLAKE2b-256 | 309e9189a13c5d88d53f33e9f37584960d7d3347b2c0937e7986eca811123e88 |
File details
Details for the file django_rest_token_expiry-1.0-py3-none-any.whl
.
File metadata
- Download URL: django_rest_token_expiry-1.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec908f1b21ed11f813b001e5a6ed83173139ebd6c9904a1dc5b7b686c8a36fcc |
|
MD5 | a70e0a5c4d1aed4b065070ddf7da28a7 |
|
BLAKE2b-256 | cafb78157e744a72eee2d983c45f2a28abe6a0099e0c61c8918f76af0fd3473b |