Flask-HTTPAuth 4.8.0
pip install Flask-HTTPAuth
Latest version
Released:
HTTP authentication for Flask routes
Navigation
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: MIT License
- Author: Miguel Grinberg
Classifiers
- Environment
- Intended Audience
- License
- Operating System
- Programming Language
Project description
Flask-HTTPAuth
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
Project details
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: MIT License
- Author: Miguel Grinberg
Classifiers
- Environment
- Intended Audience
- License
- Operating System
- Programming Language
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file Flask-HTTPAuth-4.8.0.tar.gz
.
File metadata
- Download URL: Flask-HTTPAuth-4.8.0.tar.gz
- Upload date:
- Size: 230.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66568a05bc73942c65f1e2201ae746295816dc009edd84b482c44c758d75097a |
|
MD5 | b94141e87b866e8f1e6dab494e1f9db3 |
|
BLAKE2b-256 | 22210160aa217c4df74e44a04919213f9c8af7e68551c10267b055f1e09d421c |
File details
Details for the file Flask_HTTPAuth-4.8.0-py3-none-any.whl
.
File metadata
- Download URL: Flask_HTTPAuth-4.8.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a58fedd09989b9975448eef04806b096a3964a7feeebc0a78831ff55685b62b0 |
|
MD5 | 1f92926f533ab63fa37245471f957edd |
|
BLAKE2b-256 | 83c4e64ace124b927cd1f29270050ee0e0ef5faad75a512c5c8d733961dda9ca |