Skip to main content

simple JWT handling for django REST Framework

Project description

drf-jwt

JSON Web Token based authentication using Django REST Framework, the JWT encoded in base64 is put in the headers:

Authorization: Bearer <token>

install:

pip install django-rest-jwt

let JWT do the authentification:

add 'drf_jwt.authentication.JSONWebTokenAuthentication' in authentication classes:

'DEFAULT_AUTHENTICATION_CLASSES': [
    'drf_jwt.authentication.JSONWebTokenAuthentication',
]

make endpoints to login and get the JWT:

from drf_jwt.controllers import Auth

urlpatterns = [
    path('api/login', Auth.as_view()),
]

suport GET and POST

POST:

{ login, password }

login will be the username of the authenticate function of django

GET:

return a JWT token if you are authenticate

so, one could do a Basic Authentication to the GET endpoints to receve a JWT

Project details


Download files

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

Files for django-rest-jwt, version 0.1.46
Filename, size File type Python version Upload date Hashes
Filename, size django_rest_jwt-0.1.46-py3-none-any.whl (6.3 kB) File type Wheel Python version py3 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page