Flask-HTTPAuth
HTTP authentication for Flask routes
What it is and what it does
Flask-HTTPAuth is a lightweight extension that adds HTTP authentication to Flask applications. It provides decorators for three standard authentication schemes—Basic, Digest, and Token—allowing you to protect individual routes or groups of routes with credential verification. You define a callback function to validate credentials against a database or in-memory store, then decorate your route handlers with @auth.login_required to enforce authentication.
The package integrates directly with Flask's request handling and works with standard HTTP authentication protocols. It's designed for straightforward authentication needs in REST APIs and web applications where you want to avoid the overhead of session management or third-party OAuth providers. The extension handles the HTTP protocol details—parsing Authorization headers and managing authentication state—so you focus only on credential validation logic.
Use it for:
- Protect REST API endpoints with Basic authentication for internal tools or third-party integrations.
- Add Digest authentication to web services where credentials must not be sent in plaintext.
- Implement Token-based authentication for mobile apps or single-page applications.
- Secure administrative routes in Flask applications with simple decorator-based access control.
- Build microservices that require lightweight HTTP authentication without external identity providers.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds HTTP Basic, Digest, and Token authentication decorators to Flask routes, protecting endpoints with standard credential verification.
Yes. Flask-HTTPAuth is a mature, actively maintained package with no known vulnerabilities, permissive licensing, and minimal install friction. It solves a common problem—protecting Flask routes with standard HTTP authentication—directly and without unnecessary dependencies. Install it when you need straightforward Basic, Digest, or Token auth and want to avoid building authentication from scratch.
Install
flask-httpauth on PyPI
pip
pip install flask-httpauthuv
uv add flask-httpauthpoetry
poetry add flask-httpauthInstalling Flask-HTTPAuth
Before you install
Low friction install with a single runtime dependency on flask. Active maintenance with a recent release and steady repository activity.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal obligations.
Quickstart
pip install Flask-HTTPAuth
from flask import Flask
from flask_httpauth import HTTPBasicAuth
app = Flask(__name__)
auth = HTTPBasicAuth()
users = {"john": "hello"}
@auth.verify_password
def verify_password(username, password):
if username in users and users[username] == password:
return username
@app.route('/')
@auth.login_required
def index():
return "Hello, %s!" % auth.current_user()
Verify before relying
- Whether password hashing utilities are included or require a separate dependency for production use.
- Specific HTTP status codes returned by authentication failures.
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — flask |
| Maintenance | actively maintained — 139 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,582,543/month — #2,985 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flask_httpauth-4.8.1-py3-none-any.whl
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
permissive · top 100 on PyPI
Flask-AWSCognitoIntegrates AWS Cognito user authentication into…
permissive · top 15,000 on PyPI
Flask-JWT-ExtendedAdds JSON Web Token (JWT) authentication to…
permissive · top 5,000 on PyPI
Flask-BasicAuthFlask-BasicAuth adds HTTP basic access…
permissive · top 15,000 on PyPI
dash-authAdds HTTP Basic Authentication and OpenID…
permissive · top 15,000 on PyPI
Flask-ParanoidFlask-Paranoid detects and blocks session…
permissive · top 15,000 on PyPI
aiohttp-basicauthProvides HTTP basic authentication middleware…
permissive · top 15,000 on PyPI
quart-authQuart-Auth provides session-based…
permissive · top 15,000 on PyPI
flask-cloudflaredStarts a Cloudflare TryCloudflare tunnel for a…
permissive · top 15,000 on PyPI
Flask-LoginFlask-Login handles user session management for…
permissive · top 1,000 on PyPI
Flask-BcryptFlask-Bcrypt wraps the bcrypt password-hashing…
permissive · top 5,000 on PyPI