Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

FastAPI Accounts ⚡

An open-source initiative to build the modern, complete authentication and account-management engine for FastAPI.

Status: RFC / WIP License: Apache 2.0 Discussions Python 3.10+



💡 Why We Are Building This

In the Python and Django ecosystem, django-allauth has long been the gold standard for full-featured authentication and account management. In the TypeScript world, projects like Better-Auth and Lucia transformed developer experience for modern APIs.

However, in the FastAPI ecosystem, developers still face a fragmented choice:

  1. Write 1,000+ lines of custom boilerplate for hashing, JWTs, password resets, verification emails, and OAuth state handling on every new project.
  2. Wrestle with complex generic typing and multi-file wiring in older libraries that are now in maintenance mode.
  3. Pay steep monthly fees to vendor-locked cloud auth providers (Clerk, Auth0).

FastAPI Accounts is our initiative to solve this: a modern, async-first, zero-boilerplate authentication and account management engine built natively for FastAPI, Pydantic v2, and Async SQLAlchemy 2.0.


🎯 What We Are Planning to Build

                      FASTAPI ACCOUNTS ARCHITECTURE
                                    │
    ┌─────────────────┬─────────────┴─────────────┬─────────────────┐
    ▼                 ▼                           ▼                 ▼
[Core Accounts]    [Dual Transport]            [Social OAuth]    [Modern Security]
• Email / Password • HttpOnly Cookies (SPA)    • Google & GitHub • Session Revocation
• Multi-Email per  • Bearer Tokens (Mobile)    • Safe Account    • TOTP / 2FA
  User (Verified)  • Automatic CSRF Handling     Linking (Anti-  • Passkeys /
• Reset / Verify                                 Takeover Checks)  WebAuthn

1. Radical Developer Experience (< 15 Lines of Code)

No multi-file boilerplate gymnastics. Mount all authentication and account management routes with clean dependency injection.

2. Dual-Transport for Web & Mobile

  • SPAs (Next.js, React, Vue, Svelte): Secure, SameSite=Lax, HttpOnly session cookies with CSRF protection.
  • Mobile & CLI (iOS, Flutter, React Native): Standard Authorization: Bearer <token> with refresh token rotation.

3. Real-World Multi-Email & Account Linking

  • Support multiple email addresses per user (Primary vs. Secondary, Verified vs. Unverified), matching standard production requirements.
  • Strict email verification state checks to prevent OAuth account-takeover exploits.

4. Modern Python Stack

Built cleanly for Python 3.10+, Pydantic v2, and Async SQLAlchemy 2.0.


🛠️ Proposed API Design (RFC Preview)

This is our intended developer experience. We would love your feedback on this syntax!

from fastapi import FastAPI, Depends
from fastapi_accounts import FastAPIAccounts, SQLAlchemyAdapter
from fastapi_accounts.providers import GoogleProvider, GitHubProvider

app = FastAPI(title="My API")

# 1. Initialize the account engine
accounts = FastAPIAccounts(
    adapter=SQLAlchemyAdapter(database_url="sqlite+aiosqlite:///./app.db"),
    secret_key="env:AUTH_SECRET_KEY",
    providers=[
        GoogleProvider(client_id="...", client_secret="..."),
        GitHubProvider(client_id="...", client_secret="..."),
    ],
)

# 2. Mount all auth & account endpoints in one line
app.include_router(accounts.router, prefix="/api/v1/auth", tags=["Auth"])

# 3. Protect routes with clean dependency injection
@app.get("/api/v1/profile")
async def get_profile(user = Depends(accounts.current_active_user)):
    return {"id": user.id, "primary_email": user.primary_email}

🗺️ Development Roadmap

Milestone Target Capabilities Status
Phase 0: RFC & Architecture Finalize data models, schema contracts, and API specification 🔄 In Progress
Phase 1: Core Foundation (v0.1.0-alpha) Email/Password (Argon2id), Email verification, Password reset, Multi-email models, Async SQLAlchemy 2.0 adapter, Dual-transport (Cookies + Bearer) 📋 Planned
Phase 2: Social & Sessions (v0.2.0) Google & GitHub OAuth2/OIDC, Safe account linking/unlinking, Active session tracking & device logout 📋 Planned
Phase 3: MFA & Advanced (v0.3.0) TOTP 2-Factor Authentication, WebAuthn / Passkeys, Apple / Microsoft OAuth 📋 Planned
Phase 4: Client Tooling (v0.4.0) Typed TypeScript/React client helper SDKs 📋 Planned

🤝 How You Can Get Involved

Because we are in the earliest design phase, community input directly shapes this project:

  1. Review the API Design: Does the proposed syntax fit your FastAPI projects? Share thoughts in Discussions.
  2. Request Features: Tell us what pain points you've had with existing Python auth libraries by opening an Issue.
  3. Star the Repository: Star the project to stay updated on our progress and v0.1.0-alpha release milestones!

📄 License

FastAPI Accounts will be released as open-source software licensed under the Apache License 2.0.

Metadata

Release files for fastapi-accounts 0.1.0a0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastapi-accounts 0.1.0a0
File Size Uploaded
fastapi_accounts-0.1.0a0.tar.gz 858.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-accounts 0.1.0a0
File Interpreter ABI Platform
fastapi_accounts-0.1.0a0-py3-none-any.whl Python 3 none any Details

Total release size: 866.4 kB

Release files / fastapi_accounts-0.1.0a0.tar.gz

Download URL fastapi_accounts-0.1.0a0.tar.gz
Size 858.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8294eb50c01063edbd41b67f1a2a3da240efa243d31a0423b5db7e939cfa024b
BLAKE2b-256 checksum
How to use checksums
e9855191ebb5f55dc9d5aed4a4e61263b058f31c8355a3745c57bdf8fdca120e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / fastapi_accounts-0.1.0a0-py3-none-any.whl

Download URL fastapi_accounts-0.1.0a0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b20965c44f82b120f7ae74b05823ca7677a919c52919762342248cd6d1f8eb3b
BLAKE2b-256 checksum
How to use checksums
1338f1c005040ac98caa6c513f9ccecc9a8857aa830dd1e79f8216548fa9bede
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page