### Apache Airflow version

2.6.3

### What happened

Hi, I would like to pass a custom [WSGI Middleware](https://medium.com/swlh/creating-middlewares-with-python-flask-166bd03f2fd4) to the underlying flask server.

I could theoretically do so in *webserver_config.py* by accessing `flask.current_app`:

```python
# 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_USER
```

But for this to work [the application context](https://flask.palletsprojects.com/en/2.3.x/appcontext/) should be pushed while reading the webserver config.

Thus https://github.com/apache/airflow/blob/fbeddc30178eec7bddbafc1d560ff1eb812ae37a/airflow/www/app.py#L84 should become

```python
with flask_app.app_context():
    flask_app.config.from_pyfile(settings.WEBSERVER_CONFIG, silent=True)
```

### Are you willing to submit PR?

- [X] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

"""Create a new instance of Airflow WWW app."""
    flask_app = Flask(__name__)
    flask_app.secret_key = conf.get("webserver", "SECRET_KEY")
    flask_app.config["PERMANENT_SESSION_LIFETIME"] = timedelta(minutes=settings.get_session_lifetime_config())
    webserver_config = conf.get_mandatory_value("webserver", "config_file")
    flask_app.config.from_pyfile(webserver_config, silent=True)
    flask_app.config["TESTING"] = testing
    flask_app.config["SQLALCHEMY_DATABASE_URI"] = conf.get("database", "SQL_ALCHEMY_CONN")
    instance_name = conf.get(section="webserver", key="instance_name", fallback="Airflow")
    instance_name_has_markup = conf.getboolean(
        section="webserver", key="instance_name_has_markup", fallback=False
    )
    if instance_name_has_markup:
        instance_name = Markup(instance_name).striptags()
    flask_app.config["APP_NAME"] = instance_name
    url = make_url(flask_app.config["SQLALCHEMY_DATABASE_URI"])
    if url.drivername == "sqlite" and url.database and not url.database.startswith("/"):
        raise AirflowConfigException(
            f'Cannot use relative path: `{conf.get("database", "SQL_ALCHEMY_CONN")}` to connect to sqlite. '
            "Please use absolute path such as `sqlite:////tmp/airflow.db`."
        )
    flask_app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
    flask_app.config["SESSION_COOKIE_HTTPONLY"] = True