Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling CSRF is a security risk - and not needed #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,7 @@ The plugin also includes other custom REST APIs.

b. Follow the "Enabling Authentication" section below.

7. We need to replace the `CSRF_ENABLED` attribute with `WTF_CSRF_ENABLED`.
This change is required to support the POST method when RBAC is enabled with JWT.
Please add the following property in the `{AIRFLOW_HOME}/webserver_config.py` file.

# Flask-WTF flag for CSRF
WTF_CSRF_ENABLED = False

8. Restart the Airflow Web Server
7. Restart the Airflow Web Server

### Enabling Authentication

Expand Down
8 changes: 8 additions & 0 deletions plugins/rest_api_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
from flask_jwt_extended.view_decorators import jwt_required, verify_jwt_in_request


try:
from airflow.www_rbac.app import csrf as rbac_csrf
except ImportError:
def rbac_csrf():
pass
rbac_csrf.exempt = lambda view: view

"""
CLIs this REST API exposes are Defined here: http://airflow.incubator.apache.org/cli.html
"""
Expand Down Expand Up @@ -805,6 +812,7 @@ def index(self):
@csrf.exempt # Exempt the CSRF token
@admin_expose('/api', methods=["GET", "POST"]) # for Flask Admin
# for Flask AppBuilder
@rbac_csrf.exempt # Exempt the CSRF token
@app_builder_expose('/api', methods=["GET", "POST"])
@http_token_secure # On each request
@jwt_token_secure # On each request
Expand Down