Skip to content

Commit 34f7dee

Browse files
authored
Merge pull request #346 from minrk/xsrf-event-stream
include xsrf token in event stream request
2 parents 79784e0 + 1ceca4a commit 34f7dee

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

nbgitpuller/static/js/gitsync.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
export class GitSync {
2-
constructor(baseUrl, repo, branch, depth, targetpath, path) {
2+
constructor(baseUrl, repo, branch, depth, targetpath, path, xsrf) {
33
// Class that talks to the API backend & emits events as appropriate
44
this.baseUrl = baseUrl;
55
this.repo = repo;
66
this.branch = branch;
77
this.depth = depth;
88
this.targetpath = targetpath;
99
this.redirectUrl = baseUrl + path;
10+
this._xsrf = xsrf;
1011

1112
this.callbacks = {};
1213
}
@@ -30,6 +31,7 @@ export class GitSync {
3031
start() {
3132
// Start git pulling handled by SyncHandler, declared in handlers.py
3233
let syncUrlParams = new URLSearchParams({
34+
_xsrf: this._xsrf,
3335
repo: this.repo,
3436
targetpath: this.targetpath
3537
});

nbgitpuller/static/js/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const gs = new GitSync(
2121
getBodyData('branch'),
2222
getBodyData('depth'),
2323
getBodyData('targetpath'),
24-
getBodyData('path')
24+
getBodyData('path'),
25+
getBodyData('xsrf'),
2526
);
2627

2728
const gsv = new GitSyncView(

nbgitpuller/templates/status.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
data-base-url="{{ base_url | urlencode }}"
66
data-repo="{{ repo | urlencode }}"
77
data-path="{{ path | urlencode }}"
8+
data-xsrf="{{ xsrf_token | urlencode }}"
89
{% if branch %}data-branch="{{ branch | urlencode }}"{% endif %}
910
{% if depth %}data-depth="{{ depth | urlencode }}"{% endif %}
1011
data-targetpath="{{ targetpath | urlencode }}"

0 commit comments

Comments
 (0)