Skip to content

Commit

Permalink
[AIRFLOW-2866] Fix missing CSRF token head when using RBAC UI (apache…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Silk authored and Alice Berard committed Jan 3, 2019
1 parent 2b10054 commit 5595c1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
});
});
4 changes: 2 additions & 2 deletions airflow/www_rbac/templates/appbuilder/baselayout.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@
{% block tail_js %}
{{ super() }}
<script type="text/javascript">
// below variables are used in clock.js
// below variables are used in base.js
var hostName = '{{ hostname }}';
var csrfToken = '{{ csrf_token() }}';
</script>
<script src="{{ url_for_asset('clock.js') }}" type="text/javascript"></script>
<script src="{{ url_for_asset('base.js') }}" type="text/javascript"></script>
{% endblock %}
2 changes: 1 addition & 1 deletion airflow/www_rbac/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down

0 comments on commit 5595c1e

Please sign in to comment.