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
Usage
1. Create a token:
from jwt_auth.auth import create_access_token
# Create a JWT token
access_token = create_access_token({"sub": "username"})
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.1.tar.gz
(2.5 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.1.tar.gz.
File metadata
- Download URL: jwt_auth_provider-0.1.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fcd73ced3b64f41f24132c615d78836f8d9ef6226c59ea5c2d031ccb827d9a0
|
|
| MD5 |
fafd37a6d2aae5cdf2f30b663fae0e22
|
|
| BLAKE2b-256 |
f8a48de045553083cd6b27a81328099e4d24a81b3c48d04b6041dbd484bce6dc
|
File details
Details for the file jwt_auth_provider-0.1-py3-none-any.whl.
File metadata
- Download URL: jwt_auth_provider-0.1-py3-none-any.whl
- Upload date:
- Size: 3.3 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 |
297bf26efcbd67376207123c2284f7411640e3bf7590dfc703e4158dd38b7ce8
|
|
| MD5 |
73690a956dd1c3b2a6819d1b09309471
|
|
| BLAKE2b-256 |
5fd515fb3d91423c8a3c53b65a53ddad9b07a63e2d51adc126c3ea59a251619f
|