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.6.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.6.0
File Size Uploaded Provenance Actions
Flask-HTTPAuth-4.6.0.tar.gz 230.2 kB Without provenance Details for Flask-HTTPAuth-4.6.0.tar.gz

Built distribution (wheel)

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

Total release size: 237.2 kB

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

Download URL Flask-HTTPAuth-4.6.0.tar.gz
Size 230.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2076cf86e84c6aa442ee03344bff751eae133d35a1a48931e6f99f147161b55b
BLAKE2b-256 checksum
How to use checksums
0b922e0ea6a6193dbd36925ee296ede67bc861f8219a722a33d8ec7227c7c419
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.10

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

Download URL Flask_HTTPAuth-4.6.0-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
29191747bd6a6e81980fd9c415ec1279612b06ee4a7cad8463856f2ed571ec77
BLAKE2b-256 checksum
How to use checksums
17ebec42029ee772d1506a2cb8a493622fffa7235524d8858f2ce8c2da73ffef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.10

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