vincbeck commented on code in PR #37638:
URL: https://github.com/apache/airflow/pull/37638#discussion_r1503146149
##########
airflow/www/extensions/init_views.py:
##########
@@ -323,11 +301,7 @@ def init_api_experimental(app):
app.extensions["csrf"].exempt(endpoints.api_experimental)
-def init_api_auth_provider(app):
+def init_api_auth_provider(connexion_app: connexion.FlaskApp):
Review Comment:
I know it might not be related to this change but `auth_provider` no longer
make sense, we should update it as well
```suggestion
def init_api_auth_manager(connexion_app: connexion.FlaskApp):
```
##########
airflow/www/app.py:
##########
@@ -70,7 +72,27 @@
def create_app(config=None, testing=False):
"""Create a new instance of Airflow WWW app."""
- flask_app = Flask(__name__)
+ connexion_app = connexion.FlaskApp(__name__)
+
+ @connexion_app.app.before_request
+ def before_request():
+ """Exempts the view function associated with '/api/v1' requests from
CSRF protection."""
+ if request.path.startswith("/api/v1"): # TODO: make sure this path is
correct
+ view_function = flask_app.view_functions.get(request.endpoint)
Review Comment:
```suggestion
view_function =
connexion_app.app.view_functions.get(request.endpoint)
```
##########
airflow/providers/fab/auth_manager/fab_auth_manager.py:
##########
@@ -149,19 +150,24 @@ def get_cli_commands() -> list[CLICommand]:
SYNC_PERM_COMMAND, # not in a command group
]
- def get_api_endpoints(self) -> None | Blueprint:
+ def set_api_endpoints(self, connexion_app: connexion.FlaskApp) -> None:
folder = Path(__file__).parents[0].resolve() # this is
airflow/auth/managers/fab/
with folder.joinpath("openapi", "v1.yaml").open() as f:
specification = safe_load(f)
- return FlaskApi(
+
+ swagger_ui_options = SwaggerUIOptions(
+ swagger_ui=conf.getboolean("webserver", "enable_swagger_ui",
fallback=True),
+ )
+
+ connexion_app.add_api(
specification=specification,
resolver=_LazyResolver(),
base_path="/auth/fab/v1",
- options={"swagger_ui": SWAGGER_ENABLED, "swagger_path":
SWAGGER_BUNDLE.__fspath__()},
+ swagger_ui_options=swagger_ui_options,
strict_validation=True,
validate_responses=True,
- validator_map={"body": _CustomErrorRequestBodyValidator},
- ).blueprint
+ )
+ return None
Review Comment:
Not necessary
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]