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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file django_rest_token_expiry-1.0.tar.gz.

File metadata

File hashes

Hashes for django_rest_token_expiry-1.0.tar.gz
Algorithm Hash digest
SHA256 eb6ebcc78b9ddfadfc381b4af6290fb9273ae183df1c5dc987674a5a84320376
MD5 79717a7fa120605c0b43ec9f733ae838
BLAKE2b-256 309e9189a13c5d88d53f33e9f37584960d7d3347b2c0937e7986eca811123e88

See more details on using hashes here.

File details

Details for the file django_rest_token_expiry-1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_rest_token_expiry-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec908f1b21ed11f813b001e5a6ed83173139ebd6c9904a1dc5b7b686c8a36fcc
MD5 a70e0a5c4d1aed4b065070ddf7da28a7
BLAKE2b-256 cafb78157e744a72eee2d983c45f2a28abe6a0099e0c61c8918f76af0fd3473b

See more details on using hashes here.

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