Flask-HTAuth is a Python module the integrates basic HTTP authentication into Flask.
Installation
pip install flask-htauth
or from GitHub:
git clone https://github.com/tomekwojcik/flask-htauth.git
cd flask-htauth
python setup.py develop
Example app
from flask import Flask, g
from flask.ext import htauth
import os
HTPASSWD = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'htpasswd')
app = Flask(__name__)
app.config['HTAUTH_HTPASSWD_PATH'] = HTPASSWD
app.config['HTAUTH_REALM'] = 'Top Secret Area'
auth = htauth.HTAuth(app)
@app.route('/')
def app_index():
return 'Hello, World!'
@app.route('/secret')
@htauth.authenticated
def app_secret():
return 'Hello, ' + g.htauth_user + '!'
Product's homepage
Here are some key features of "Flask-HTAuth":
· Basic auth,
· Support for MD5, SHA and crypt htpasswd password encrypting.
Requirements:
· Python