File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 2121from datetime import timedelta
2222
2323import connexion
24+ from flask import request
2425from flask_appbuilder import SQLA
2526from flask_wtf .csrf import CSRFProtect
2627from markupsafe import Markup
@@ -73,6 +74,15 @@ def create_app(config=None, testing=False):
7374 """Create a new instance of Airflow WWW app."""
7475 connexion_app = connexion .FlaskApp (__name__ )
7576
77+ @connexion_app .app .before_request
78+ def before_request ():
79+ """Exempts the view function associated with '/api/v1' requests from CSRF protection."""
80+ if request .path .startswith ("/api/v1" ): # TODO: make sure this path is correct
81+ view_function = flask_app .view_functions .get (request .endpoint )
82+ if view_function :
83+ # Exempt the view function from CSRF protection
84+ connexion_app .app .extensions ["csrf" ].exempt (view_function )
85+
7686 connexion_app .add_middleware (
7787 CORSMiddleware ,
7888 connexion .middleware .MiddlewarePosition .BEFORE_ROUTING ,
You can’t perform that action at this time.
0 commit comments