Skip to main content

A Django app to conduct web-based polls.

Project description

JW-NX


About package

This package provides an authentication mechanism for Django Rest Framework based on JSON Web Tokens in the browser-backed up 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): A user's session is tied to the specific machine and logging can be segregated per usage.
  • JWT-base tokens: The token can have an embedded expiration time and further metadata for other applications.
  • 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.
  • Access and refresh token: Like the rest-framework-simplejwt package, this package create refresh token and access token in login attempt and authentication is working with the access token.
  • Other applications sharing the JWT private key can also decrypt the JWT.
  • This package provides some endpoint for getting some data about the statuses of tokens.

Note : Token_key that provided by knox, is set in payload of access and refresh token.

Installation

For installing this package in your environment run these commands:

 pip install jw_nx
 pip install django-rest-knox

Quick start

  • Add "jw_nx and knox" to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
    ...
    'knox',
    'jw_nx',
    ...
    ]

  • Include the polls URLconf in your project urls.py like this::

path('jw_nx/', include('jw_nx.urls')),

  • Run python manage.py makemigrations.

  • Run python manage.py migrate.

  • Add 'jw_nx.auth.JSONWebTokenKnoxAuthentication' to REST_FRAMEWORK like this::

    REST_FRAMEWORK =[ ... 'DEFAULT_AUTHENTICATION_CLASSES': ('jw_nx.auth.JSONWebTokenKnoxAuthentication',), ... ]

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

jw-nx-1.1.3.tar.gz (17.3 kB view details)

Uploaded Source

File details

Details for the file jw-nx-1.1.3.tar.gz.

File metadata

  • Download URL: jw-nx-1.1.3.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for jw-nx-1.1.3.tar.gz
Algorithm Hash digest
SHA256 6d7951f44f250ee863424456f86735e810a9e1b401dcf44f7dbb424af6e75435
MD5 b52448f92af96e72a23b5e23631255e8
BLAKE2b-256 f9108dfaeea92f760837a32b895ed15526ad4a33764b14afe406f9645ac69af8

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