FastAPI Auth Template is a universal authentication template for FastAPI, based on the core of the FastAPI Users library.
Suitable for MVPs, pet projects, and production-ready systems with flexible strategies, token transport methods, and extendable models.
- JWT — stateless access tokens (in-memory)
- Database (DB) — persistent access tokens with revocation support
- Bearer — via
Authorization: Bearer <token>header - Cookies — secure
HttpOnlycookies (frontend-friendly)
- OAuth2 / OpenID Connect — external authentication via Google, Yandex, etc.
fastapi— main frameworkfastapi-users— user management frameworksqlalchemy— ORM for users and tokensalembic— schema migrationsasyncpg— async PostgreSQL driver- Extendable models:
User,AccessToken,RefreshToken - Async
UserManagerwith custom logic support
git clone https://github.com/r66cha/fastapi-auth-template.git
cd fastapi-auth-templatemake install-uvmake install-reqmake alembic-upgrademake superuser- with uvicorn (development)
make urun- with gunicorn
make runThis project is licensed under the MIT License.
r66cha