A simple Django app for django-ninja authentication tokens
Project description
ninja-authtoken
A simple Django app for django-ninja authentication tokens
source code : Visit GitHub!
installaton
pip install ninja-authtoken
add ninja-authtoken to django installed app
INSTALLED_APPS = [
...
"authtoken",
...
]
set user model in settings.py
Example {AUTH_USER_MODEL = "accounts.USER"}
Usage
for routers
from authtoken.security import APIKeyAuth
auth = APIKeyAuth()
@router.get('profile/', auth=auth)
def profile(request):
return f"Hello, {request.user}!"
Api Base
from ninja import NinjaAPI
from authtoken.security import APIKeyAuth
# ...
api = NinjaAPI(auth=APIKeyAuth())
# ...
@api.get("/profile")
def profile(request):
return f"Hello, {request.user}!"
ـ The token is generated automatically as soon as a new user is created by Signal ـ
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
ninja_authtoken-1.0.1.tar.gz
(5.8 kB
view details)
Built Distribution
File details
Details for the file ninja_authtoken-1.0.1.tar.gz
.
File metadata
- Download URL: ninja_authtoken-1.0.1.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06092e36027e63a577276c1921e094e68abda5bd837339248a5fcecdaad8b599 |
|
MD5 | cc1aa14a880fc11e11e112c17c11046b |
|
BLAKE2b-256 | 14b756ef149ea2a97fb47de84123d20cffb7ec2d082cb4a765a50208f18aceeb |
File details
Details for the file ninja_authtoken-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: ninja_authtoken-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 281beff64cd7dd0886757f8a320181737e396d38e7e5040832adebd67dfc1e53 |
|
MD5 | 5118bcfe07d5d78195cbae807b293ad3 |
|
BLAKE2b-256 | 48ac36d28a45ff6018b439376559292e11baf29e1676e28c2ee0476a5658b58d |