Flask-Login

User authentication and session management for Flask applications

Library
PyPI
v0.6.3
3,676stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
51/100Fair
Development Activity0
Maintenance20
Community84
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
75/100Good
Architecture76
Code Quality78
Innovation60
Learning Curve85

Flask-Login handles the parts of user authentication that Flask itself doesn’t provide an opinion on: tracking a user’s logged-in state across requests, storing that state in the session, protecting views that require login, and handling “remember me” cookies. It deliberately does not implement password hashing, user storage, or OAuth flows itself — instead it expects you to provide a User class (via a mixin) and a user_loader callback, and it wires up the session-tracking plumbing around whatever authentication backend you choose.

This narrow scope is why it’s become the de facto standard for session-based auth in Flask apps: it’s small, focused, and composes cleanly with any credential-checking logic (a database lookup, an OAuth callback, LDAP, etc.) without dictating your data model. It’s maintained under Max Countryman’s GitHub account with a long history dating back to its original author Matthew Frazier, and remains a required dependency in most Flask tutorials and starter kits that need logged-in users.

What You Get

  • A LoginManager extension object that hooks into Flask’s request lifecycle to load the current user from the session on every request
  • UserMixin providing default implementations of the properties Flask-Login expects (is_authenticated, is_active, get_id)
  • @login_required view decorator that redirects unauthenticated requests to a configurable login view
  • current_user proxy giving templates and views access to the logged-in user (or an anonymous user object) without passing it explicitly
  • “Remember me” cookie support for persisting login across browser sessions, with configurable duration and secure cookie options
  • Signals (via blinker) for login/logout events that other extensions or app code can subscribe to

Common Use Cases

  • Adding session-based login/logout to a Flask app backed by a SQL database of users
  • Protecting admin or account-settings views so only authenticated users can reach them
  • Implementing “remember me” functionality so users stay logged in across browser restarts
  • Integrating with Flask-SQLAlchemy or Flask-Security-style extensions that need a pluggable session/auth layer
  • Exposing the logged-in user to Jinja2 templates via current_user for conditional rendering (e.g. showing a logout link)

Under The Hood

Architecture - The extension centers on login_manager.py (LoginManager, ~460 lines), which registers Flask request hooks (before_request/context processors) to load the user identified in the session via a developer-supplied user_loader callback, and exposes current_user as a Werkzeug local proxy. utils.py implements the functional API (login_user, logout_user, login_required, fresh_login_required) built on top of the manager, while mixins.py supplies default UserMixin/AnonymousUserMixin base classes so applications don’t have to hand-implement the small interface Flask-Login expects. Tech Stack - A thin extension over Flask (>=2.3) and Werkzeug (>=2.3.2), using Python’s standard session cookie signing (via Flask’s itsdangerous-backed sessions) rather than its own crypto, and blinker-based signals for the login/logout event hooks; packaged with flit_core as a minimal single-purpose sdist/wheel. Code Quality - The tests/test_login.py suite is the primary test surface, exercising login/logout flows, remember-cookie behavior, and view protection against a small Flask test app fixture; the codebase itself is compact (~1,100 lines across src/flask_login), keeping the surface area easy to audit line-by-line. API Design - The public API is intentionally minimal and Flask-idiomatic: a single LoginManager to configure, a handful of decorators and functions (login_required, login_user, logout_user), and one mixin to inherit from, which is why it integrates into nearly any Flask app’s user model with only a few lines of glue code.

Used by 5 apps in this directory

Python
90%
Apache 2.0

Apache Airflow

Data Engineering

46,530

Define, schedule, and monitor complex data workflows as Python code — with a powerful UI, 80+ provider integrations, and battle-tested scalability across thousands of production deployments.

View details
96
Repo Health
89
Technical
66
Dependency
Built with
Python90%
Updated today
Python
79%
Apache 2.0

changedetection.io

Monitoring

33,241

Self-hosted website change detection with AI-powered smart alerts, browser automation, price tracking, and 85+ notification channels.

View details
90
Repo Health
80
Technical
69
Dependency
Built with
Python79%
Updated 3 days ago
TypeScript
50%
Other

Dify

No Code Platforms · AI Development · Developer Tools

152,883

Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.

View details
92
Repo Health
85
Technical
71
Dependency
Built with
TypeScript50%
Python47%
Updated today
Python
45%
Other

Redash

Analytics · Data Engineering

28,754

Redash lets anyone connect to 35+ SQL and NoSQL data sources, write a query in the browser, and turn the result into a shared dashboard — no separate BI suite required.

View details
85
Repo Health
74
Technical
61
Dependency
Built with
Python45%
JavaScript31%
TypeScript17%
Updated yesterday
Python
53%
AGPL 3.0

Speakr

AI Assistants

3,652

Self-hosted AI transcription with speaker diarization, smart tagging, and multi-user collaboration — your recordings stay on your infrastructure.

View details
82
Repo Health
79
Technical
70
Dependency
Built with
Python53%
HTML26%
JavaScript17%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search