Skip to main content

Knox-fortified JSON Web Tokens for Django REST Framework

Project description

DRF JWT + Knox

Build Status codecov PyPI version Requirements Status Maintainability Rating

This package provides an authentication mechanism for Django REST Framework based on JSON Web Tokens in the browser backed up by Knox-powered tokens in the database.

This package aims to take the better parts of both worlds, including:

  • Expirable tokens: The tokens may be manually expired in the database, so a user can log out of all other logged-in places, or everywhere.
  • Different tokens per login attempt (per user-agent), meaning that a user's session is tied to the specific machine and logging can be segregated per usage.
  • JWT-based tokens, so the token can have an embedded expiration time, and further metadata for other applications.
  • Tokens are generated via OpenSSL so that they are cryptographically more secure.
  • Only the tokens' hashes are stored in the database, so that even if the database gets dumped, an attacker cannot impersonate people through existing credentials
  • Other applications sharing the JWT private key can also decrypt the JWT

Usage

Add this application and knox to INSTALLED_APPS in your settings.py.

Then, add this app's routes to some of your urlpatterns.

You can use the verify endpoint to verify whether a token is valid or not (which may be useful in a microservice architecture).

Tests

Tests are automated with tox and run on Travis-CI automatically. You can check the status in Travis, or just run tox from the command line.

Contributing

This project uses the GitHub Flow approach for contributing, meaning that we would really appreciate it if you would send patches as Pull Requests in GitHub. If for any reason you prefer to send patches by email, they are also welcome and will end up being integrated here.

License

This code is released under the Apache Software License Version 2.0.

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-jwt-knox-0.1.2.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drf_jwt_knox-0.1.2-py2.py3-none-any.whl (12.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file drf-jwt-knox-0.1.2.tar.gz.

File metadata

  • Download URL: drf-jwt-knox-0.1.2.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for drf-jwt-knox-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e441d64b021eb8baaef41eed546f9c8dd414f532ce8756b65031fa970cbead51
MD5 ea4a187c30222019f5db2903ba61302e
BLAKE2b-256 e685d44e707b0852edc0f64434804740e4984aad63b48d1c28b56360258dbd94

See more details on using hashes here.

File details

Details for the file drf_jwt_knox-0.1.2-py2.py3-none-any.whl.

File metadata

  • Download URL: drf_jwt_knox-0.1.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for drf_jwt_knox-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 420b495aeefdfd6ac9f491a21f5d82918c6bff90f90502e067196a3311a87418
MD5 fc6f2cd8a719c29f2ef1795f040e887f
BLAKE2b-256 0323aeb5021a1f54c8df573bbded2cbde5c39a07ce1c513f2d7d61726e66a6bf

See more details on using hashes here.

Supported by

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