Skip to main content

A JWT authentication to django project

Project description

Django DRF JWT

Goal of this simple package is to create a simple JWT authentication for Django apps. This should be easy to configue and easy to adapt to your needs and preferences. Package is based on PyJWT

Setup

  1. Install package

    pip install django-drf-jwt
    
  2. Update REST_FRAMEWORK settings:

    REST_FRAMEWORK = {
        # ...
        "DEFAULT_AUTHENTICATION_CLASSES": (
            "django_drf_jwt.authentication.JWTAuthentication",
        )
        # ...
    }
    
  3. Add new field in your User model and add this to your settings file

    JWT_DRF = {
        # JWT_USER_SECRET_FIELD - MUST BE DEFINED - This must be filed in User object
        "JWT_USER_SECRET_FIELD": "secret",
    }
    

    Available settings:

    # These are default settings
    JWT_DRF = {
        "JWT_SECRET": settings.SECRET_KEY,
        "JWT_USER_ID_FIELD": "pk",
        "JWT_USER_SECRET_FIELD": None,  # MUST BE DEFINED - This must be a
        "JWT_PAYLOAD_HANDLER": "django_drf_jwt.handlers.payload_handler",
        "JWT_AUTH_HEADER_PREFIX": "JWT",
    }
    

Issues

Issues and bugs be free to contact me directly

NOTE

I plan to push this package to PyPi when ready! :)

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

django-drf-mjwt-0.0.1b1.tar.gz (7.0 kB view details)

Uploaded Source

File details

Details for the file django-drf-mjwt-0.0.1b1.tar.gz.

File metadata

  • Download URL: django-drf-mjwt-0.0.1b1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for django-drf-mjwt-0.0.1b1.tar.gz
Algorithm Hash digest
SHA256 3a78e681ed75bb2fca2b958634dac0cde879fe80543ee00e9f1402218533ccba
MD5 634afcf8cbf2a1ea76f1f1beabade176
BLAKE2b-256 8aea6cea8eeea563f6837b2246b05230161bc25648f1a43480fc9a7d07b39066

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