Add secure token to djnago-rest-framework
Project description
Add “drf_secure_token” to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [ ... 'rest_framework', 'drf_secure_token', ]
Add following lines to your settings.py:
REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': [ 'rest_framework.authentication.BasicAuthentication', 'drf_secure_token.authentication.SecureTokenAuthentication', ] }
For updating token add this middleware to your MIDDLEWARE_CLASSES:
MIDDLEWARE_CLASSES = ( ... 'drf_secure_token.middleware.UpdateTokenMiddleware', )
Add UPDATE_TOKEN to your ‘dev’ settings if you don’t want to update token in DEBUG mode:
UPDATE_TOKEN = False
Add TOKEN_AGE to your settings:
TOKEN_AGE = 60*10 # 10 min
Run python manage.py migrate to create the drf_secure_token models.
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
drf-secure-token-1.0.4.tar.gz
(4.9 kB
view hashes)
Built Distribution
Close
Hashes for drf_secure_token-1.0.4-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60c6d0a1568dfd7a6159fbe84b5104c9626609f6a9996088cba7060d39c65161 |
|
MD5 | e3be5ef19ac2655f6c18538753989458 |
|
BLAKE2b-256 | a5325ef17ed302b7304d37cecfa0bbf4fde325b1f273ec85d3dd7fc372f9bf3c |