Python flask_httpauth.HTTPBasicAuth() Examples
The following are 3
code examples of flask_httpauth.HTTPBasicAuth().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
flask_httpauth
, or try the search function
.
Example #1
Source File: server.py From eNMS with GNU General Public License v3.0 | 5 votes |
def register_extensions(self): self.auth = HTTPBasicAuth() self.csrf = CSRFProtect() self.csrf.init_app(self)
Example #2
Source File: auth.py From ukbrest with MIT License | 5 votes |
def setup_http_basic_auth(self): auth = HTTPBasicAuth() self.verify_password = auth.verify_password(self.verify_password) return auth
Example #3
Source File: server.py From captcha22 with MIT License | 5 votes |
def __init__(self, source): self.auth = HTTPBasicAuth() self.source = source @self.auth.verify_password def verify_password(username, password): for user in self.source.users: if user.username == username: return check_password_hash(user.password, password) return False @self.auth.error_handler def unauthorized(): # return 403 instead of 401 to prevent browsers from displaying the default # auth dialog return make_response(jsonify({'message': 'Unauthorized access'}), 403) self.second_auth = HTTPTokenAuth() @self.second_auth.verify_token def verify_token(token): self.clean_tokens() headers = request.headers token = headers.get("X-Api-Key") for user in self.source.users: for current_token in user.tokens: if user.tokens[current_token][0] == token: return True return False @self.second_auth.error_handler def unauthorized(): # return 403 instead of 401 to prevent browsers from displaying the default # auth dialog return make_response(jsonify({'message': 'Unauthorized access'}), 403)