Skip to main content

django_jwt_middleware

django_jwt_middleware is a package used for authorize django request with JSON Web Tokens

1. Installation

pip3 install django-jwt-middleware

or clone

git clone https://github.com/rizki4106/django_jwt_middleware.git

2. Example

with http cookie

If you store jwt key on cookie you can use @verify_jwt_cookie decorator

from django_jwt_middleware import verify_jwt_cookie
from rest_framework.decorators import api_view
from rest_framework.response import Response

@verify_jwt_cookie(cookie_name="example-token", jwt_key="supersecretkey", algorithm="HS256")
def hello_world(request):
    return Response(data={
        "message": "hello world"
    })

@verify_jwt_cookie takes 3 arguments

name type description
cookie_name string name of cookie that store your jwt token
jwt_key string jsonwebtoken secret key
algoritm string algorithm to decoded your jwt key default is HS256

With http headers

If you store jwt key http headers you can use @verify_jwt_header decorator

from django_jwt_middleware import verify_jwt_header
from rest_framework.decorators import api_view
from rest_framework.response import Response

@verify_jwt_header(header_name="example-token", jwt_key="supersecretkey", algorithm="HS256")
def hello_world(request):
    return Response(data={
        "message": "hello world"
    })

@verify_jwt_header takes 3 arguments

name type description
header_name string name of header that store your jwt token
jwt_key string jsonwebtoken secret key
algoritm string algorithm to decoded your jwt key default is HS256

3. Response

Type Description
success Will continue to request destination
failed Return http status code 403 with the message in it

Metadata

Release files for django-jwt-middleware 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-jwt-middleware 1.0.2
File Size Uploaded Provenance Actions
django_jwt_middleware-1.0.2.tar.gz 3.3 kB Without provenance Details for django_jwt_middleware-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-jwt-middleware 1.0.2
File Interpreter ABI Platform Actions
django_jwt_middleware-1.0.2-py3-none-any.whl Python 3 none any Details for django_jwt_middleware-1.0.2-py3-none-any.whl

Total release size: 7.2 kB

Release files / django_jwt_middleware-1.0.2.tar.gz

Download URL django_jwt_middleware-1.0.2.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
913da0418fbb5b8f51b9f244e9a7bde175a120ab0537641c87055306cbfa789c
BLAKE2b-256 checksum
How to use checksums
a41b74b7c7a2afde059b33c0fa8c6403a549fb2e254372c623a966b76d85cef4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / django_jwt_middleware-1.0.2-py3-none-any.whl

Download URL django_jwt_middleware-1.0.2-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f0d47392a73ffe892bf697ba0346e03cd3bcc66c18b9cd9ac2dc9e8b5d878b7f
BLAKE2b-256 checksum
How to use checksums
db6bb8ecf610fc2f14f948d2398bc899d51c7cb6e4e6cdfc256846c5ffc3615c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Security for django-jwt-middleware 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page