move CustomBasicAuth override to import

This commit is contained in:
Jim Moffet
2022-07-01 11:34:51 -07:00
parent f8f87e0596
commit e9a3b3d5e3
2 changed files with 18 additions and 19 deletions

View File

@@ -3,15 +3,13 @@ from flask import jsonify, request
class CustomBasicAuth(BasicAuth):
"""
Description:
Usage:
Description:
Override BasicAuth to permit anonymous healthcheck at /_status?simple=true
"""
def check_credentials(self, username, password):
# here, for example, you can search user in the database by passed `username` and `password`, etc.
return username == 'user' and password == 'password'
def challenge(self):
if "/_status" in request.url:
if request.args.get('elb', None) or request.args.get('simple', None):
return jsonify(status="ok"), 200
return super(CustomBasicAuth, self).challenge()
custom_basic_auth = CustomBasicAuth()