https://github.com/sreekarnv/fastauth
Production-ready authentication library for FastAPI with OAuth 2.0, RBAC, session management, and comprehensive account features. Includes JWT tokens, email verification, password reset, and auto-generated documentation.
https://github.com/sreekarnv/fastauth
fastapi fastapi-auth jwt-authentication oauth2 python sqlalchemy
Last synced: 4 months ago
JSON representation
Production-ready authentication library for FastAPI with OAuth 2.0, RBAC, session management, and comprehensive account features. Includes JWT tokens, email verification, password reset, and auto-generated documentation.
- Host: GitHub
- URL: https://github.com/sreekarnv/fastauth
- Owner: sreekarnv
- License: mit
- Created: 2025-12-20T02:14:13.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2026-01-16T22:48:27.000Z (5 months ago)
- Last Synced: 2026-01-18T05:12:22.949Z (5 months ago)
- Topics: fastapi, fastapi-auth, jwt-authentication, oauth2, python, sqlalchemy
- Language: Python
- Homepage: https://sreekarnv.github.io/fastauth/
- Size: 1.98 MB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# FastAuth
[](https://pypi.org/project/sreekarnv-fastauth/)
[](https://opensource.org/licenses/MIT)
[](https://github.com/sreekarnv/fastauth/actions/workflows/ci.yml)
[](https://codecov.io/gh/sreekarnv/fastauth)
[](https://www.python.org/downloads/)
**NextAuth-inspired pluggable authentication for FastAPI.**
FastAuth gives you a complete auth system — credentials, OAuth, email verification, password reset, RBAC, and JWT — without locking you into any particular database or ORM.
---
## Features
- **Multiple providers** — email/password, Google OAuth, GitHub OAuth
- **Pluggable adapters** — SQLAlchemy (SQLite, PostgreSQL, MySQL) or bring your own
- **JWT & database sessions** — stateless tokens or server-side sessions
- **Cookie delivery** — HttpOnly, Secure, SameSite out of the box
- **Email flows** — verification and password reset with customizable transports
- **RBAC** — roles and fine-grained permissions on any route
- **Event hooks** — intercept sign-in/sign-up and modify JWT payloads
- **RS256 / JWKS** — rotate keys and expose a JWKS endpoint for microservices
- **CLI** — scaffold a project, check dependencies, generate secrets
---
## Install
```bash
pip install "sreekarnv-fastauth[standard]"
```
| Extra | Includes |
|-------|----------|
| `standard` | FastAPI, JWT (joserfc), SQLAlchemy, Argon2 |
| `oauth` | httpx (Google, GitHub OAuth) |
| `email` | aiosmtplib, Jinja2 |
| `redis` | redis-py async |
| `postgresql` | asyncpg |
| `cli` | typer, rich |
| `all` | everything |
---
## Quick start
```python
from contextlib import asynccontextmanager
from fastapi import Depends, FastAPI
from fastauth import FastAuth, FastAuthConfig
from fastauth.adapters.sqlalchemy import SQLAlchemyAdapter
from fastauth.api.deps import require_auth
from fastauth.providers.credentials import CredentialsProvider
adapter = SQLAlchemyAdapter(engine_url="sqlite+aiosqlite:///./auth.db")
auth = FastAuth(FastAuthConfig(
secret="change-me", # fastauth generate-secret
providers=[CredentialsProvider()],
adapter=adapter.user,
token_adapter=adapter.token,
))
@asynccontextmanager
async def lifespan(app: FastAPI):
await adapter.create_tables()
yield
app = FastAPI(lifespan=lifespan)
auth.mount(app) # registers /auth/signup, /auth/signin, /auth/signout, …
@app.get("/dashboard")
async def dashboard(user=Depends(require_auth)):
return {"hello": user["email"]}
```
```bash
uvicorn main:app --reload
```
---
## Documentation
Full documentation at **[sreekarnv.github.io/fastauth](https://sreekarnv.github.io/fastauth)**
- [Installation](https://sreekarnv.github.io/fastauth/getting-started/installation/)
- [Quick Start](https://sreekarnv.github.io/fastauth/getting-started/quick-start/)
- [Configuration](https://sreekarnv.github.io/fastauth/getting-started/configuration/)
- [How it Works](https://sreekarnv.github.io/fastauth/concepts/how-it-works/)
- [Guides](https://sreekarnv.github.io/fastauth/guides/basic/)
- [API Reference](https://sreekarnv.github.io/fastauth/api/fastauth/)
---
## License
MIT License - see [LICENSE](./LICENSE) for details.