-
Notifications
You must be signed in to change notification settings - Fork 16.6k
Closed
Labels
affected_version:2.6Issues Reported for 2.6Issues Reported for 2.6area:webserverWebserver related IssuesWebserver related Issuesgood first issuekind:bugThis is a clearly a bugThis is a clearly a bug
Description
Apache Airflow version
2.6.3
What happened
Hi, I would like to pass a custom WSGI Middleware to the underlying flask server.
I could theoretically do so in webserver_config.py by accessing flask.current_app:
# webserver_config.py
from flask import current_app
from airflow.www.fab_security.manager import AUTH_REMOTE_USER
class MyAuthMiddleware:
def __init__(self, wsgi_app) -> None:
self.wsgi_app = wsgi_app
def __call__(self, environ: dict, start_response):
print("--> Custom authenticating logic")
environ["REMOTE_USER"] = "username"
return self.wsgi_app(environ, start_response)
current_app.wsgi_app = MyAuthMiddleware(current_app.wsgi_app)
AUTH_TYPE = AUTH_REMOTE_USERBut for this to work the application context should be pushed while reading the webserver config.
Thus
Line 84 in fbeddc3
| flask_app.config.from_pyfile(settings.WEBSERVER_CONFIG, silent=True) |
with flask_app.app_context():
flask_app.config.from_pyfile(settings.WEBSERVER_CONFIG, silent=True)Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
affected_version:2.6Issues Reported for 2.6Issues Reported for 2.6area:webserverWebserver related IssuesWebserver related Issuesgood first issuekind:bugThis is a clearly a bugThis is a clearly a bug