mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 19:48:25 -04:00
move CustomBasicAuth override to import
This commit is contained in:
@@ -39,6 +39,7 @@ from werkzeug.local import LocalProxy
|
|||||||
from app import proxy_fix, webauthn_server
|
from app import proxy_fix, webauthn_server
|
||||||
from app.asset_fingerprinter import asset_fingerprinter
|
from app.asset_fingerprinter import asset_fingerprinter
|
||||||
from app.config import configs
|
from app.config import configs
|
||||||
|
from app.custom_auth import CustomBasicAuth
|
||||||
from app.extensions import antivirus_client, redis_client, zendesk_client
|
from app.extensions import antivirus_client, redis_client, zendesk_client
|
||||||
from app.formatters import (
|
from app.formatters import (
|
||||||
convert_to_boolean,
|
convert_to_boolean,
|
||||||
@@ -593,16 +594,16 @@ def init_jinja(application):
|
|||||||
jinja_loader = jinja2.FileSystemLoader(template_folders)
|
jinja_loader = jinja2.FileSystemLoader(template_folders)
|
||||||
application.jinja_loader = jinja_loader
|
application.jinja_loader = jinja_loader
|
||||||
|
|
||||||
class CustomBasicAuth(BasicAuth):
|
# class CustomBasicAuth(BasicAuth):
|
||||||
"""
|
# """
|
||||||
Description:
|
# Description:
|
||||||
Override BasicAuth to permit anonymous healthcheck at /_status?simple=true
|
# Override BasicAuth to permit anonymous healthcheck at /_status?simple=true
|
||||||
"""
|
# """
|
||||||
def challenge(self):
|
# def challenge(self):
|
||||||
if "/_status" in request.url:
|
# if "/_status" in request.url:
|
||||||
if request.args.get('elb', None) or request.args.get('simple', None):
|
# if request.args.get('elb', None) or request.args.get('simple', None):
|
||||||
return jsonify(status="ok"), 200
|
# return jsonify(status="ok"), 200
|
||||||
return super(CustomBasicAuth, self).challenge()
|
# return super(CustomBasicAuth, self).challenge()
|
||||||
|
|
||||||
def setup_basic_auth(application):
|
def setup_basic_auth(application):
|
||||||
application.basic_auth = CustomBasicAuth(application)
|
application.basic_auth = CustomBasicAuth(application)
|
||||||
|
|||||||
@@ -4,14 +4,12 @@ from flask import jsonify, request
|
|||||||
class CustomBasicAuth(BasicAuth):
|
class CustomBasicAuth(BasicAuth):
|
||||||
"""
|
"""
|
||||||
Description:
|
Description:
|
||||||
|
Override BasicAuth to permit anonymous healthcheck at /_status?simple=true
|
||||||
Usage:
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
def challenge(self):
|
||||||
def check_credentials(self, username, password):
|
if "/_status" in request.url:
|
||||||
# here, for example, you can search user in the database by passed `username` and `password`, etc.
|
if request.args.get('elb', None) or request.args.get('simple', None):
|
||||||
return username == 'user' and password == 'password'
|
return jsonify(status="ok"), 200
|
||||||
|
return super(CustomBasicAuth, self).challenge()
|
||||||
|
|
||||||
custom_basic_auth = CustomBasicAuth()
|
custom_basic_auth = CustomBasicAuth()
|
||||||
Reference in New Issue
Block a user