JWT authentication, registration and user management for FastKit/FastAPI applications
Project description
What is FastKit Auth?
FastKit Auth is part of the FastKit ecosystem. It provides ready-to-use authentication building blocks for FastAPI applications built on top of fastkit-core.
⚠️ Early release. The API may change before 1.0. Not recommended for production yet.
Features
- JWT Authentication — Access + refresh token flow
- User Registration — With email verification via OTP token
- Password Reset — Token-based reset flow via email
- Profile Management — Get and update authenticated user profile
- Password Hashing — Bcrypt via passlib
- Auth Dependencies —
get_current_user,get_current_verified_user,get_current_superuser - Email Sending — Integrated with mailbridge
Roadmap
- 2FA (TOTP + Backup codes)
- RBAC (Roles + Permissions)
- Decorators (
@require_permission,@require_role) - Audit Logging
- Rate Limiting + Account Locking
Requirements
- Python 3.12+
- PostgreSQL
fastkit-core >= 0.4.0mailbridge >= 2.0.0
Installation
pip install fastkit-auth
Configuration
FastKit Auth reads configuration through fastkit-core's ConfigManager.
You need app and auth config modules in your project.
config/auth.py (example):
JWT_ALGORITHM = "HS256"
JWT_TOKEN_SECRET = "your-secret"
JWT_LIFETIME_SECONDS = 3600
JWT_REFRESH_SECRET_KEY = "your-refresh-secret"
JWT_REFRESH_LIFETIME_SECONDS = 604800
PASSWORD_ENCRYPTION_SCHEMES = ["bcrypt"]
config/app.py (example):
MAIL_PROVIDER = "smtp"
MAIL_API_KEY = ""
MAIL_ENDPOINT = "smtp://localhost:1025"
MAIL_FROM = "noreply@example.com"
Quick Start
from fastapi import FastAPI
from fastkit_auth.authentication.router import router as auth_router
from fastkit_auth.users.router import registration_router, profile_router
from fastkit_core.database import init_async_database
from fastkit_core.config import ConfigManager
from fastkit_core.http.exception_handlers import register_exception_handlers
configuration = ConfigManager(modules=['app', 'database', 'auth'])
init_async_database(configuration)
app = FastAPI()
register_exception_handlers(app=app)
app.include_router(auth_router)
app.include_router(registration_router)
app.include_router(profile_router)
Endpoints
| Method | Path | Description |
|---|---|---|
POST |
/registration |
Register a new user |
PUT |
/verify-email?token= |
Verify email with OTP token |
POST |
/auth/login |
Login, returns JWT tokens |
POST |
/auth/reset-password |
Request password reset email |
POST |
/auth/update-password |
Set new password using reset token |
GET |
/profile |
Get authenticated user profile |
PUT |
/profile |
Update authenticated user profile |
Auth Dependencies
Use these in your route dependencies:
from fastkit_auth.authentication.dependencies import (
get_current_user,
get_current_verified_user,
get_current_superuser,
)
@router.get("/me")
async def me(user = Depends(get_current_user)):
return user
@router.get("/admin")
async def admin_only(user = Depends(get_current_superuser)):
...
User Model
from fastkit_auth.users.models import User
| Field | Type | Description |
|---|---|---|
id |
UUID | Primary key |
first_name |
str | |
last_name |
str | |
email |
str | Unique |
hashed_password |
str | Bcrypt |
is_active |
bool | Activated after email verification |
is_verified |
bool | Email verified |
is_superuser |
bool | Superuser flag |
email_verified_at |
datetime | Timestamp of verification |
Links
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
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 fastkit_auth-0.1.1.tar.gz.
File metadata
- Download URL: fastkit_auth-0.1.1.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2241b5970f8dfffb2438fe4b016a1db24a384f89f454cdae88c126b8deb00f98
|
|
| MD5 |
440ac2e26ceaab76bed445c2f5c095d5
|
|
| BLAKE2b-256 |
8d984414934d44f0c1ac2d0e8dc46b9daae1c6f7c959e71091a240c530d9a928
|
Provenance
The following attestation bundles were made for fastkit_auth-0.1.1.tar.gz:
Publisher:
test_publish.yml on fastkit-org/fastkit-auth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastkit_auth-0.1.1.tar.gz -
Subject digest:
2241b5970f8dfffb2438fe4b016a1db24a384f89f454cdae88c126b8deb00f98 - Sigstore transparency entry: 1569553657
- Sigstore integration time:
-
Permalink:
fastkit-org/fastkit-auth@2b729c9f6eeaa835e007c30b806455284ce24f56 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/fastkit-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test_publish.yml@2b729c9f6eeaa835e007c30b806455284ce24f56 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fastkit_auth-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fastkit_auth-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62005c6423ad24f08077f4b06377f212eb89c7b1ce67ba66126220c3a55fbcfc
|
|
| MD5 |
8ab58ddd0cebbe589c92856e3ca7e63c
|
|
| BLAKE2b-256 |
3231fd16b6abfcc589dd042d5dd35919104e3196b9c1c6a4049f2cf31a53d256
|
Provenance
The following attestation bundles were made for fastkit_auth-0.1.1-py3-none-any.whl:
Publisher:
test_publish.yml on fastkit-org/fastkit-auth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastkit_auth-0.1.1-py3-none-any.whl -
Subject digest:
62005c6423ad24f08077f4b06377f212eb89c7b1ce67ba66126220c3a55fbcfc - Sigstore transparency entry: 1569553739
- Sigstore integration time:
-
Permalink:
fastkit-org/fastkit-auth@2b729c9f6eeaa835e007c30b806455284ce24f56 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/fastkit-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test_publish.yml@2b729c9f6eeaa835e007c30b806455284ce24f56 -
Trigger Event:
push
-
Statement type: