Simple JWT-based authentication using Django and Django-ninja
Project description
django-ninja-simple-jwt
Provides simple JWT based stateless authentication for Django-ninja
Quick start
Install package:
pip install django-ninja-simple-jwt
add ninja_simple_jwt
to list of INSTALLED_APPS
in Django settings:
# settings.py
INSTALLED_APPS = [
...,
"ninja_simple_jwt"
]
Expose Django-ninja
's API and add ninja_simple_jwt
;s auth API endpoint router to the API, ie:
# urls.py
from ninja import NinjaAPI
from ninja_simple_jwt.auth.views.api import auth_router
from django.urls import path
api = NinjaAPI()
api.add_router("/auth/", auth_router)
urlpatterns = [path("api/", api.urls)]
This would provide 4 available auth API endpoints for mobile and web sign in and token refresh:
- {{server_url}}/api/auth/mobile/sign-in
- {{server_url}}/api/auth/mobile/token-refresh
- {{server_url}}/api/auth/web/sign-in
- {{server_url}}/api/auth/web/token-refresh
Finally, to provide a resource API, you can use the HttpJwtAuth
as the auth argument when instantiating a Router, ie:
# views.py
from ninja_simple_jwt.auth.ninja_auth import HttpJwtAuth
from ninja import Router
some_resource_router = Router(auth=HttpJwtAuth())
@some_resource_router.get("/hello")
def hello(request):
return "Hello world"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-ninja-simple-jwt-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9beb3838157e62575d82db3ac81de3884869b3d13e68ffe7a9f878a903e04bd0 |
|
MD5 | 77c411bb81f3027a2b0caf63ccadd1d0 |
|
BLAKE2b-256 | d445e4ee60101d76abd440b1cf34814a9055c31cbb90eadac3c5ff40f2995248 |
Close
Hashes for django_ninja_simple_jwt-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65583b36ff4e320917c82823e115b42948fcbb753cbe0f8588138cda38787ae0 |
|
MD5 | a22780b0ab24fe0349cbbda31e7ae23d |
|
BLAKE2b-256 | 3454c5ee23ec20b17869bac863a5c0c1b291b3d16b1fa7ad0cc3cac44db709b8 |