fastapi-login
Flask-Login like package for FastAPI
Decision gist · record as of 2026-08-14
Yes, if you need straightforward JWT or cookie-based authentication in FastAPI without building token logic from scratch. The low install friction, permissive license, and stable API make it a practical choice. However, note the aging maintenance status—verify compatibility with your fastapi version and consider whether the package receives updates for security patches or breaking changes in its dependencies.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a secret key (generate via `import secrets; print(secrets.token_hex(24))`).
- For OAuth2PasswordRequestForm, the python-multipart package is required.
- Low install friction with a pure-Python wheel.
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use, modify, and distribute this package freely in both open-source and commercial projects with minimal restrictions.
last release 2024-12-14 (608 days) · last repo commit 2025-05-20 · 820 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 85,141 downloads/mo, #13,946 on PyPI
Alternatives
Verify before relying
pip install fastapi-login
from fastapi import FastAPI, Depends
from fastapi_login import LoginManager
app = FastAPI()
manager = LoginManager('your-secret-key', token_url='/auth/token')
@manager.user_loader()
def load_user(email: str):
return {'email': email} # return user or None
@app.get('/protected')
def protected(user=Depends(manager)):
return {'user': user}- Whether the aging maintenance status affects compatibility with the latest fastapi versions.
- Performance characteristics under high-concurrency token validation loads.
- Whether cookie-based auth is suitable for your deployment model (SPA vs. traditional server-rendered).
What it is and what it does
FastAPI-Login provides a Flask-Login-like authentication layer for FastAPI, handling JWT token creation, validation, and user session management. It wraps FastAPI's OAuth2 security model to let you protect routes with a simple dependency injection pattern, supporting both header-based bearer tokens and cookie-based sessions. The core workflow is: define a user loader callback, create tokens on login, then use the LoginManager as a route dependency to enforce authentication.
The package depends on fastapi, pyjwt, and typing-extensions. It supports Python 3.8 through 3.13 and runs on any OS. You provide the user lookup logic (database, in-memory store, etc.) and the package handles token lifecycle—encoding, decoding, expiration, and optional cookie management with HTTPOnly flags.
Use it for
- Protect FastAPI routes with JWT bearer tokens, requiring users to authenticate before accessing sensitive endpoints.
- Implement cookie-based login flows for traditional web applications served by FastAPI, with automatic HTTPOnly flag handling.
- Build multi-user APIs where each request carries a user identity decoded from a signed token.
- Add custom exception handling for unauthenticated requests, e.g., redirecting to a login page.
- Manage token expiration policies per-request, e.g., short-lived access tokens with longer refresh windows.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need straightforward JWT or cookie-based authentication in FastAPI without building token logic from scratch.
The low install friction, permissive license, and stable API make it a practical choice. However, note the aging maintenance status—verify compatibility with your fastapi version and consider whether the package receives updates for security patches or breaking changes in its dependencies.
Install
fastapi-login on PyPI
Before you install
Low install friction with a pure-Python wheel. Maintenance status is aging—last commit was 2025-05-20, with the latest release on 2024-12-14, though the repository remains active and not archived.
Requires a secret key (generate via `import secrets; print(secrets.token_hex(24))`). For OAuth2PasswordRequestForm, the python-multipart package is required.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely in both open-source and commercial projects with minimal restrictions.
Quickstart
pip install fastapi-login
from fastapi import FastAPI, Depends
from fastapi_login import LoginManager
app = FastAPI()
manager = LoginManager('your-secret-key', token_url='/auth/token')
@manager.user_loader()
def load_user(email: str):
return {'email': email} # return user or None
@app.get('/protected')
def protected(user=Depends(manager)):
return {'user': user}
Verify before relying
- Whether the aging maintenance status affects compatibility with the latest fastapi versions.
- Performance characteristics under high-concurrency token validation loads.
- Whether cookie-based auth is suitable for your deployment model (SPA vs. traditional server-rendered).
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release <4.0,>=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 3 packagestyping-extensionsfastapipyjwt |
| Maintenance | Aging 608 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 85,141 / month, #13,946 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: fastapi_login-1.10.3-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “jwt token login”
- fastapi-loginAdds session and token-based user authentication to FastAPI…
- Flask-JWT-ExtendedAdds JSON Web Token (JWT) authentication to Flask applications,…
- drf-jwtAdds JSON Web Token (JWT) authentication to Django REST Framework…
Give your agent the search over MCP, or paste the wish link into any chat.
More Dynamic Content packages
MarkupSafe provides a text object that escapes special characters so untrusted strings can be safely embedded in HTML and XML without injection attacks.
Jinja2 is a templating engine that renders dynamic content by combining templates with Python-like syntax and data, supporting template inheritance, macros, autoescaping, and sandboxed execution.
Soupsieve is a CSS selector library designed to work with Beautiful Soup 4 to select, match, and filter HTML and XML elements using modern CSS selectors from CSS level 1 through CSS level 4 specifications.
Install it if you use Beautiful Soup for HTML or XML parsing and want modern CSS selector support.
Werkzeug is a WSGI utility library providing request/response objects, URL routing, an interactive debugger, HTTP utilities, and a development server for building web applications.
Flask is a lightweight WSGI web application framework for building web applications in Python, from simple single-page sites to complex multi-route applications.
Mako compiles Python-embedded templates into Python modules for fast rendering, supporting layout inheritance, custom functions, and direct Python expressions within template syntax.
See also fastapi-auth0 · Flask-Login · fastapi-cloudauth · fastapi-users · propelauth-fastapi · fastapi-sessions · axioms-fastapi · fastapi-cognito · fastapi-sso · fastapi-csrf-protect