Skip to content

Commit e98fba2

Browse files
committed
allow disabling xsrf check
for deployments that want to grant unfettered access, even from anonymous API requests
1 parent de60f6d commit e98fba2

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

notebook/base/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def check_origin(self, origin_to_satisfy_tornado=""):
324324

325325
def check_xsrf_cookie(self):
326326
"""Bypass xsrf checks when token-authenticated"""
327-
if self.token_authenticated:
327+
if self.token_authenticated or self.settings.get('disable_check_xsrf', False):
328328
# Token-authenticated requests do not need additional XSRF-check
329329
# Servers without authentication are vulnerable to XSRF
330330
return

notebook/notebookapp.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ def init_settings(self, ipython_app, kernel_manager, contents_manager,
193193
logout_handler_class=ipython_app.logout_handler_class,
194194
password=ipython_app.password,
195195
xsrf_cookies=True,
196+
disable_check_xsrf=ipython_app.disable_check_xsrf,
196197

197198
# managers
198199
kernel_manager=kernel_manager,
@@ -560,6 +561,22 @@ def _token_changed(self, name, old, new):
560561
"""
561562
)
562563

564+
disable_check_xsrf = Bool(False, config=True,
565+
help="""Disable cross-site-request-forgery protection
566+
567+
Jupyter notebook 4.3.1 introduces protection from cross-site request forgeries,
568+
requiring API requests to either:
569+
570+
- originate from the (validated with XSRF cookie and token), or
571+
- authenticate with a token
572+
573+
Some anonymous compute resources still desire the ability to run code,
574+
completely without authentication.
575+
These services can disable all authentication and security checks,
576+
with the full knowledge of what that implies.
577+
"""
578+
)
579+
563580
open_browser = Bool(True, config=True,
564581
help="""Whether to open in a browser after starting.
565582
The specific browser used is platform dependent and

0 commit comments

Comments
 (0)