Skip to main content

Add secure token to djnago-rest-framework

Project description

  1. Add “drf_secure_token” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'rest_framework',
        'drf_secure_token',
    ]
  2. Add following lines to your settings.py:

    REST_FRAMEWORK = {
        'DEFAULT_AUTHENTICATION_CLASSES': [
            'rest_framework.authentication.BasicAuthentication',
            'drf_secure_token.authentication.SecureTokenAuthentication',
         ]
    }
  3. For updating token add this middleware to your MIDDLEWARE_CLASSES:

    MIDDLEWARE_CLASSES = (
        ...
        'drf_secure_token.middleware.UpdateTokenMiddleware',
    )
  4. Add UPDATE_TOKEN to your ‘dev’ settings if you don’t want to update token in DEBUG mode:

    UPDATE_TOKEN = False
  5. Add TOKEN_AGE to your settings:

    TOKEN_AGE = 60*10 # 10 min
  6. Run python manage.py migrate to create the drf_secure_token models.

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

drf-secure-token-1.0.4.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

drf_secure_token-1.0.4-py2-none-any.whl (11.9 kB view details)

Uploaded Python 2

File details

Details for the file drf-secure-token-1.0.4.tar.gz.

File metadata

  • Download URL: drf-secure-token-1.0.4.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for drf-secure-token-1.0.4.tar.gz
Algorithm Hash digest
SHA256 906901e1db8411851e21dd7ee9c273f0d96752d56b2ecad9bd179a347ca9b4bb
MD5 2ce21e401b4434cc4303f657b34444c3
BLAKE2b-256 8111e5d84102f1c7c1f5571ad056ada43f911afcd8b45da6ba7db1080c9e0bbc

See more details on using hashes here.

File details

Details for the file drf_secure_token-1.0.4-py2-none-any.whl.

File metadata

File hashes

Hashes for drf_secure_token-1.0.4-py2-none-any.whl
Algorithm Hash digest
SHA256 60c6d0a1568dfd7a6159fbe84b5104c9626609f6a9996088cba7060d39c65161
MD5 e3be5ef19ac2655f6c18538753989458
BLAKE2b-256 a5325ef17ed302b7304d37cecfa0bbf4fde325b1f273ec85d3dd7fc372f9bf3c

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