import typing from urllib.parse import unquote, urlparse from flask import request, current_app def get_auth_proxy() -> typing.Optional[str]: auth_proxy = unquote(request.args.get("auth_proxy", "")) if auth_proxy and urlparse( auth_proxy ).netloc not in current_app.config.get("ALLOWED_HOSTS"): auth_proxy = None return auth_proxy