Created
May 26, 2016 21:45
-
-
Save seanbehan/8fa65637ca3ab850d10911edcba4b608 to your computer and use it in GitHub Desktop.
using basic auth in flask
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Flask Basic Auth | |
@app.before_request | |
def basic_auth(): | |
auth = request.authorization | |
if not auth or (auth.username != 'username' and auth.password != 'password'): | |
return response('Authentication required.', 401, {'WWW-Authenticate': 'Basic realm="Login Required"'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment