Skip to main content

django-ninja-jwt-basic

GitHub License Tests Codecov PyPI - Python Version PyPI - Versions from Framework Classifiers PyPI - Version Code style: black Linting: Ruff

Simple JWT-based authentication designed for Django and Django Ninja. This package aims to provide a minimalistic approach to JWT authentication with the least amount of dependencies, making it easy to integrate and use in your projects.

Installation

pip install django-ninja-jwt-basic

Configuration

Add the following settings to your Django settings:

JWT_SECRET_KEY = 'your_secret key' # Required

Add the app to your INSTALLED_APPS in your Django settings:

INSTALLED_APPS = [
    ...
    'django_ninja_jwt_basic',
    ...
]

Usage

Next, add router to your Django Ninja API and protect your endpoints

from ninja import NinjaAPI
from django_ninja_jwt_basic import JWTAuth

api = NinjaAPI(auth=JWTAuth())
api.add_router('/auth', 'django_ninja_jwt_basic.router')

This will add the following endpoint to your API:

  • /auth/login - POST - Login endpoint

    • Request body:

      {
          "username": "your_username",
          "password": "your_password"
      }
      
    • Response body:

      {
          "token": "your_access_token"
      }
      

If you don't want protect all endpoints, you can use JWTAuth class directly in your endpoints or routers like below:

from ninja import Router
from django_ninja_jwt_basic import JWTAuth

router = Router(auth=JWTAuth())

@router.get('/protected')
def protected(request):
    return {'message': 'This is a protected endpoint'}
from django_ninja_jwt_basic import JWTAuth

@api.get('/protected', auth=JWTAuth())
def protected(request):
    return {'message': 'This is a protected endpoint'}

You can find more information about protecting endpoints in the Django Ninja documentation

Metadata

Release files for django-ninja-jwt-basic 0.1.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-ninja-jwt-basic 0.1.2
File Size Uploaded Provenance
django_ninja_jwt_basic-0.1.2.tar.gz 3.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-ninja-jwt-basic 0.1.2
File Interpreter ABI Platform
django_ninja_jwt_basic-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 8.2 kB

Release files / django_ninja_jwt_basic-0.1.2.tar.gz

Download URL django_ninja_jwt_basic-0.1.2.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f811755ac43e9b61750bb148e71d789193f3717685670c7f3fcbffe08c05afa6
BLAKE2b-256 checksum
How to use checksums
70f2f0683bc60f6079766a39b3dd1c36d6581a5ab4d9d08ab54999fccbae01d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1023-azure

Release files / django_ninja_jwt_basic-0.1.2-py3-none-any.whl

Download URL django_ninja_jwt_basic-0.1.2-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eca2680eae29794d41ea427885ee9c4c1ce0350f3116b5f8100ec26499b1f855
BLAKE2b-256 checksum
How to use checksums
8077252cb29ccdafbd026020734991b896b82c833361225522f676f5ebdaf7c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1023-azure

Security for django-ninja-jwt-basic 0.1.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