Skip to content

Commit

Permalink
Merge pull request #346 from minrk/xsrf-event-stream
Browse files Browse the repository at this point in the history
include xsrf token in event stream request
  • Loading branch information
consideRatio authored Mar 29, 2024
2 parents 79784e0 + 1ceca4a commit 34f7dee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion nbgitpuller/static/js/gitsync.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
export class GitSync {
constructor(baseUrl, repo, branch, depth, targetpath, path) {
constructor(baseUrl, repo, branch, depth, targetpath, path, xsrf) {
// Class that talks to the API backend & emits events as appropriate
this.baseUrl = baseUrl;
this.repo = repo;
this.branch = branch;
this.depth = depth;
this.targetpath = targetpath;
this.redirectUrl = baseUrl + path;
this._xsrf = xsrf;

this.callbacks = {};
}
Expand All @@ -30,6 +31,7 @@ export class GitSync {
start() {
// Start git pulling handled by SyncHandler, declared in handlers.py
let syncUrlParams = new URLSearchParams({
_xsrf: this._xsrf,
repo: this.repo,
targetpath: this.targetpath
});
Expand Down
3 changes: 2 additions & 1 deletion nbgitpuller/static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const gs = new GitSync(
getBodyData('branch'),
getBodyData('depth'),
getBodyData('targetpath'),
getBodyData('path')
getBodyData('path'),
getBodyData('xsrf'),
);

const gsv = new GitSyncView(
Expand Down
1 change: 1 addition & 0 deletions nbgitpuller/templates/status.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
data-base-url="{{ base_url | urlencode }}"
data-repo="{{ repo | urlencode }}"
data-path="{{ path | urlencode }}"
data-xsrf="{{ xsrf_token | urlencode }}"
{% if branch %}data-branch="{{ branch | urlencode }}"{% endif %}
{% if depth %}data-depth="{{ depth | urlencode }}"{% endif %}
data-targetpath="{{ targetpath | urlencode }}"
Expand Down

0 comments on commit 34f7dee

Please sign in to comment.