Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_rest_token_expiry-1.0.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

django_rest_token_expiry-1.0-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page