Skip to content

Commit 27bab21

Browse files
Gabriel SilkFokko
Gabriel Silk
authored andcommitted
[AIRFLOW-2866] Fix missing CSRF token head when using RBAC UI (#3804)
1 parent 470f415 commit 27bab21

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

airflow/www_rbac/static/js/clock.js airflow/www_rbac/static/js/base.js

+7
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,11 @@ function displayTime() {
3333
$(document).ready(function () {
3434
displayTime();
3535
$('span').tooltip();
36+
$.ajaxSetup({
37+
beforeSend: function(xhr, settings) {
38+
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
39+
xhr.setRequestHeader("X-CSRFToken", csrfToken);
40+
}
41+
}
42+
});
3643
});

airflow/www_rbac/templates/appbuilder/baselayout.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@
6767
{% block tail_js %}
6868
{{ super() }}
6969
<script type="text/javascript">
70-
// below variables are used in clock.js
70+
// below variables are used in base.js
7171
var hostName = '{{ hostname }}';
7272
var csrfToken = '{{ csrf_token() }}';
7373
</script>
74-
<script src="{{ url_for_asset('clock.js') }}" type="text/javascript"></script>
74+
<script src="{{ url_for_asset('base.js') }}" type="text/javascript"></script>
7575
{% endblock %}

airflow/www_rbac/webpack.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const BUILD_DIR = path.resolve(__dirname, './static/dist');
3535
const config = {
3636
entry: {
3737
connectionForm: `${STATIC_DIR}/js/connection_form.js`,
38-
clock: `${STATIC_DIR}/js/clock.js`,
38+
base: `${STATIC_DIR}/js/base.js`,
3939
graph: `${STATIC_DIR}/js/graph.js`,
4040
ganttChartD3v2: `${STATIC_DIR}/js/gantt-chart-d3v2.js`,
4141
main: `${STATIC_DIR}/css/main.css`,

0 commit comments

Comments
 (0)