Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

JSON Web Tokens with a Knox-powered database backend

Project Description

DRF JWT + Knox

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


Add this application and knox to INSTALLED_APPS in your

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 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.


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.


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

Release History

Release History

This version
History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
drf_jwt_knox-0.1.0-py2.py3-none-any.whl (10.3 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Oct 11, 2016
drf-jwt-knox-0.1.0.tar.gz (10.8 kB) Copy SHA256 Checksum SHA256 Source Oct 11, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting