JWT authentication package for FastAPI
Project description
JWT Auth for FastAPI
This is a simple JWT authentication package for FastAPI that provides:
- JWT token creation
- Token verification and decoding
- Password hashing and verification
- FastAPI dependency injection for secure endpoints
Installation
pip install jwt-auth-provider
Usage
1. Create a token:
from jwt_auth.auth import create_access_token
# Create a JWT token
access_token = create_access_token({"sub": "username"}, secret_key, algorithm)
2. Use the dependency in FastAPI:
from fastapi import FastAPI, Depends
from jwt_auth.dependencies import get_user_from_token
app = FastAPI()
@app.get("/users/me")
def read_users_me(current_user: str = Depends(get_user_from_token)):
return {"user": current_user}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jwt_auth_provider-0.2.tar.gz
(2.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jwt_auth_provider-0.2.tar.gz.
File metadata
- Download URL: jwt_auth_provider-0.2.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33535cf99c37dd659b7e0e269ae217369b05a29ff632e82f8b9907ec31a39a3b
|
|
| MD5 |
02962dfa15f959576750dc33db5eedc7
|
|
| BLAKE2b-256 |
f2617dfb664475b422612cd7d759d048b7ed41ebbdf9ab759a1b62135f7c10cb
|
File details
Details for the file jwt_auth_provider-0.2-py3-none-any.whl.
File metadata
- Download URL: jwt_auth_provider-0.2-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3beb80ebdfb529f53a4fb1a8cac7854a1458c548aba5511666909f7f73ca90b
|
|
| MD5 |
25734a6d0979c2ef0276bfd467bcb206
|
|
| BLAKE2b-256 |
f7ef981c8d82182076b4e18f1434329746be54af3350c1b87a9278256b09f110
|