File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -506,6 +506,9 @@ def check_referer(self):
506
506
507
507
def check_xsrf_cookie (self ):
508
508
"""Bypass xsrf cookie checks when token-authenticated"""
509
+ if not hasattr (self , "_jupyter_user" ):
510
+ # Called too early, will be checked later
511
+ return
509
512
if self .token_authenticated or self .settings .get ("disable_check_xsrf" , False ):
510
513
# Token-authenticated requests do not need additional XSRF-check
511
514
# Servers without authentication are vulnerable to XSRF
@@ -593,8 +596,11 @@ async def prepare(self):
593
596
594
597
# self.current_user for tornado's @web.authenticated
595
598
# self._jupyter_user for backward-compat in deprecated get_current_user calls
599
+ # and our own private checks for whether .current_user has been set
596
600
self .current_user = self ._jupyter_user = user
601
+ # complete initial steps which require auth to resolve first:
597
602
self .set_cors_headers ()
603
+ self .check_xsrf_cookie ()
598
604
return super ().prepare ()
599
605
600
606
# ---------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments