From 03af8f80f6321bc8e644fc2d4054cae98eadef2a Mon Sep 17 00:00:00 2001 From: Gabriel Silk Date: Fri, 24 Aug 2018 15:00:28 -0700 Subject: [PATCH] [AIRFLOW-2866] Fix missing CSRF token head when using RBAC UI --- airflow/www_rbac/static/js/{clock.js => base.js} | 7 +++++++ airflow/www_rbac/templates/appbuilder/baselayout.html | 4 ++-- airflow/www_rbac/webpack.config.js | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) rename airflow/www_rbac/static/js/{clock.js => base.js} (84%) diff --git a/airflow/www_rbac/static/js/clock.js b/airflow/www_rbac/static/js/base.js similarity index 84% rename from airflow/www_rbac/static/js/clock.js rename to airflow/www_rbac/static/js/base.js index afde7c2545f37..ea065792a533a 100644 --- a/airflow/www_rbac/static/js/clock.js +++ b/airflow/www_rbac/static/js/base.js @@ -33,4 +33,11 @@ function displayTime() { $(document).ready(function () { displayTime(); $('span').tooltip(); + $.ajaxSetup({ + beforeSend: function(xhr, settings) { + if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) { + xhr.setRequestHeader("X-CSRFToken", csrfToken); + } + } + }); }); diff --git a/airflow/www_rbac/templates/appbuilder/baselayout.html b/airflow/www_rbac/templates/appbuilder/baselayout.html index 1653a909d02b2..89e32cae783ec 100644 --- a/airflow/www_rbac/templates/appbuilder/baselayout.html +++ b/airflow/www_rbac/templates/appbuilder/baselayout.html @@ -67,9 +67,9 @@ {% block tail_js %} {{ super() }} - + {% endblock %} diff --git a/airflow/www_rbac/webpack.config.js b/airflow/www_rbac/webpack.config.js index 29b99f408f20e..16f394cc616b9 100644 --- a/airflow/www_rbac/webpack.config.js +++ b/airflow/www_rbac/webpack.config.js @@ -35,7 +35,7 @@ const BUILD_DIR = path.resolve(__dirname, './static/dist'); const config = { entry: { connectionForm: `${STATIC_DIR}/js/connection_form.js`, - clock: `${STATIC_DIR}/js/clock.js`, + base: `${STATIC_DIR}/js/base.js`, graph: `${STATIC_DIR}/js/graph.js`, ganttChartD3v2: `${STATIC_DIR}/js/gantt-chart-d3v2.js`, main: `${STATIC_DIR}/css/main.css`,