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
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.3.tar.gz.
File metadata
- Download URL: jwt_auth_provider-0.1.3.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 |
8cf4391deea652a124b4973689b425642ca4bf224975f3ba3fafa2b16a8c638b
|
|
| MD5 |
bb7168faf957035112198bada50b0c5e
|
|
| BLAKE2b-256 |
33d88b997381b8f1f35fabf3b1c17a445c477f7bec4cad90aa019127dfe299ff
|
File details
Details for the file jwt_auth_provider-0.1.3-py3-none-any.whl.
File metadata
- Download URL: jwt_auth_provider-0.1.3-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 |
8429470a98067652d4f26bb8d6eb0ca9d43e2d6cb259cb0143b5129cae0be082
|
|
| MD5 |
6145f16041bb693da9b5fe90aac6e140
|
|
| BLAKE2b-256 |
305e42b5a54aec701e983747f5bb17c8abaf1dac7ae326da44e9aefb0fa55b9c
|