Skip to content

Commit 08f7189

Browse files
committed
only allow CORS exception when auth is enabled
1 parent 9acf6a8 commit 08f7189

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

notebook/base/handlers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,11 +530,17 @@ def options(self, *args, **kwargs):
530530
# if authorization header is requested,
531531
# that means the request is token-authenticated.
532532
# avoid browser-side rejection of the preflight request.
533-
# only allow this exception if allow_origin has not been specified.
533+
# only allow this exception if allow_origin has not been specified
534+
# and notebook authentication is enabled.
535+
# If the token is not valid, the 'real' request will still be rejected.
534536
requested_headers = self.request.headers.get('Access-Control-Request-Headers', '').split(',')
535537
if requested_headers and any(
536538
h.strip().lower() == 'authorization'
537539
for h in requested_headers
540+
) and (
541+
# FIXME: it would be even better to check specifically for token-auth,
542+
# but there is currently no API for this.
543+
self.login_available
538544
) and (
539545
self.allow_origin
540546
or self.allow_origin_pat

0 commit comments

Comments
 (0)