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-mjwt
    
  2. Add django_drf_jwt to your INSTALLED_APPS:

    INSTALLED_APPS = [
     # ...
     "django_drf_jwt",
     # ...
     ]
    
  3. Update REST_FRAMEWORK settings:

    REST_FRAMEWORK = {
        # ...
        "DEFAULT_AUTHENTICATION_CLASSES": (
            "django_drf_jwt.authentication.JWTAuthentication",
        )
        # ...
    }
    
  4. 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",
    }
    

Developing

To setup environment for local developing install requirements from requirements.txt file. Make sure that you write tests for your implementation.

Issues

If you have any suggestions or you see some issues and bugs be free to contact me!

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.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

django_drf_mjwt-0.0.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file django_drf_mjwt-0.0.1.tar.gz.

File metadata

  • Download URL: django_drf_mjwt-0.0.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for django_drf_mjwt-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a35bfecf35a7c995bf2a1f85ef07b6c9283de70c3db41b2f633e442ec5e7d7ca
MD5 ac1313bd39a5be3c794fbb156ec8acd6
BLAKE2b-256 8f6d9df2923e9831010a9ef4704367354cee0384c9c2e2e42205405112e58cb2

See more details on using hashes here.

File details

Details for the file django_drf_mjwt-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_drf_mjwt-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 02582b608bf0b923620fd59ce5c0715cc8369ba4acc0551a2e370a016d699dbb
MD5 ec2360aa8fb8dcf7acc3f174bc391529
BLAKE2b-256 19f04de368250ebc9cc78301d021d0079980ecd89952a0eea5f902958a26d755

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