miguelgrinberg
Flask-HTTPAuth
Python

Simple extension that provides Basic, Digest and Token HTTP authentication for Flask routes

Last updated Jul 8, 2026
1.3k
Stars
235
Forks
10
Issues
0
Stars/day
Attention Score
94
Language breakdown
No language data available.
โ–ธ Files click to expand
README

Flask-HTTPAuth ==============

Build status codecov

Simple extension that provides Basic, Digest and Token HTTP authentication for Flask routes.

Installation


The easiest way to install this is through pip.
pip install Flask-HTTPAuth

Basic authentication example


from flask import Flask
from flask_httpauth import HTTPBasicAuth
from werkzeug.security import generatepasswordhash, checkpasswordhash

app = Flask(name) auth = HTTPBasicAuth()

users = { "john": generatepasswordhash("hello"), "susan": generatepasswordhash("bye") }

@auth.verify_password def verify_password(username, password): if username in users and \ checkpasswordhash(users.get(username), password): return username

@app.route('/') @auth.login_required def index(): return "Hello, %s!" % auth.current_user()

if name == 'main': app.run()

Note: See the documentation for more complex examples that involve password hashing and custom verification callbacks.

Digest authentication example


from flask import Flask
from flask_httpauth import HTTPDigestAuth

app = Flask(name) app.config['SECRET_KEY'] = 'secret key here' auth = HTTPDigestAuth()

users = { "john": "hello", "susan": "bye" }

@auth.get_password def get_pw(username): if username in users: return users.get(username) return None

@app.route('/') @auth.login_required def index(): return "Hello, %s!" % auth.username()

if name == 'main': app.run()

Resources


๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท miguelgrinberg/Flask-HTTPAuth ยท Updated daily from GitHub