Skip to main content

Flask-HTTPAuth

Build status codecov

Simple extension that provides Basic and Digest 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 generate_password_hash, check_password_hash

app = Flask(__name__)
auth = HTTPBasicAuth()

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

@auth.verify_password
def verify_password(username, password):
    if username in users and \
            check_password_hash(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

Metadata

Release files for Flask-HTTPAuth 4.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Flask-HTTPAuth 4.5.0
File Size Uploaded Provenance Actions
Flask-HTTPAuth-4.5.0.tar.gz 36.0 kB Without provenance Details for Flask-HTTPAuth-4.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for Flask-HTTPAuth 4.5.0
File Interpreter ABI Platform Actions
Flask_HTTPAuth-4.5.0-py3-none-any.whl Python 3 none any Details for Flask_HTTPAuth-4.5.0-py3-none-any.whl

Total release size: 42.7 kB

Release files / Flask-HTTPAuth-4.5.0.tar.gz

Download URL Flask-HTTPAuth-4.5.0.tar.gz
Size 36.0 kB
Tags Source
SHA-256 checksum
How to use checksums
395040fda2854df800d15e84bc4a81a5f32f1d4a5e91eee554936f36f330aa29
BLAKE2b-256 checksum
How to use checksums
d9c8b4d278366fcb1c25d2b8552a5f4764961af46a794135499079b6ff9f4895
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.7.3

Release files / Flask_HTTPAuth-4.5.0-py3-none-any.whl

Download URL Flask_HTTPAuth-4.5.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e16067ba3378ea366edf8de4b9d55f38c0a0cbddefcc0f777a54b3fce1d99392
BLAKE2b-256 checksum
How to use checksums
3891dbdb73482b566ea16df7851140f224ffad57dbb8ea6021cbaedb7eb2072d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.7.3

Security for Flask-HTTPAuth 4.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

4.5.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page