Skip to content

Commit efdbef1

Browse files
committed
get xsrf from cookie, not body data
so that it can't be skimmed with a GET of the page
1 parent c5bb329 commit efdbef1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

notebook/static/base/js/utils.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,12 @@ define([
681681
settings = _add_auth_header(settings);
682682
return $.ajax(url, settings);
683683
};
684+
685+
var _get_cookie = function (name) {
686+
// from tornado docs: http://www.tornadoweb.org/en/stable/guide/security.html
687+
var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
688+
return r ? r[1] : undefined;
689+
}
684690

685691
var _add_auth_header = function (settings) {
686692
/**
@@ -691,7 +697,7 @@ define([
691697
settings.headers = {};
692698
}
693699
if (!settings.headers.Authorization) {
694-
var xsrf_token = get_body_data('xsrfToken');
700+
var xsrf_token = _get_cookie('_xsrf');
695701
if (xsrf_token) {
696702
settings.headers['X-XSRFToken'] = xsrf_token;
697703
}

notebook/templates/page.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115

116116
<body class="{% block bodyclasses %}{% endblock %}"
117117
{% block params %}
118-
data-xsrf-token="{{xsrf_token | urlencode}}"
119118
{% if logged_in and token %}
120119
data-jupyter-api-token="{{token | urlencode}}"
121120
{% endif %}

0 commit comments

Comments
 (0)