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.7.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.7.0
File Size Uploaded Provenance Actions
Flask-HTTPAuth-4.7.0.tar.gz 230.3 kB Without provenance Details for Flask-HTTPAuth-4.7.0.tar.gz

Built distribution (wheel)

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

Total release size: 237.2 kB

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

Download URL Flask-HTTPAuth-4.7.0.tar.gz
Size 230.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f7199e7bad20d5b68b3f0b62bddfca7637c55087e9d02f605ae26e0de479fd94
BLAKE2b-256 checksum
How to use checksums
de281681359136718332e97e763c0eec2e9da03e801f9349216f2cf1fb0a6ab4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

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

Download URL Flask_HTTPAuth-4.7.0-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a237e4c8ec1d339298a0eb88e5af2ca36117949b621631649462800e57e1ba37
BLAKE2b-256 checksum
How to use checksums
09a4e9b3b4bbf6456578e0b457b46f1e70bf8b65e4b59cf830fa56938a587347
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.12

Security for Flask-HTTPAuth 4.7.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.7.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