Skip to content

milemik/django-drf-jwt

Repository files navigation

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",
    }

Issues

Issues and bugs be free to contact me directly

NOTE

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages