Skip to content

Commit b371d8a

Browse files
committed
prose review
1 parent c231fd2 commit b371d8a

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

docs/source/changelog.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,19 @@ For more detailed information, see `GitHub <https://github.com/jupyter/notebook>
2525
where malicious forms could create untitled files and start kernels
2626
(no remote execution or modification of existing files)
2727
for users of certain browsers (Firefox, Internet Explorer / Edge).
28+
All previous notebook releases are affected.
2829

2930
Bug fixes:
3031

3132
- Fix carriage return handling
32-
- Make the font size more robust against fickle brow
33+
- Make the font size more robust against fickle browsers
3334
- Ignore resize events that bubbled up and didn't come from window
35+
- Add Authorization to allowed CORS headers
3436

3537
Other improvements:
3638

3739
- Better docs for token-based authentication
3840
- Further highlight token info in log output when autogenerated
39-
- Add Authorization to allowed CORS headers
4041

4142
See the 4.3.1 milestone on GitHub for a complete list of
4243
`issues <https://github.com/jupyter/notebook/issues?utf8=%E2%9C%93&q=is%3Aissue%20milestone%3A4.3.1>`__

notebook/auth/login.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,21 @@ def get_token(cls, handler):
117117
@classmethod
118118
def should_check_origin(cls, handler):
119119
"""Should the Handler check for CORS origin validation?
120-
120+
121121
Origin check should be skipped for token-authenticated requests.
122+
123+
Returns:
124+
- True, if Handler must check for valid CORS origin.
125+
- False, if Handler should skip origin check since requests are token-authenticated.
122126
"""
123127
return not cls.is_token_authenticated(handler)
124-
128+
125129
@classmethod
126130
def is_token_authenticated(cls, handler):
127-
"""Check if the handler has been authenticated by a token.
128-
129-
This is used to signal certain things, such as:
130-
131+
"""Returns True if handler has been token authenticated. Otherwise, False.
132+
133+
Login with a token is used to signal certain things, such as:
134+
131135
- permit access to REST API
132136
- xsrf protection
133137
- skip origin-checks for scripts
@@ -152,8 +156,8 @@ def get_user(cls, handler):
152156
user_id = handler.get_secure_cookie(handler.cookie_name)
153157
else:
154158
cls.set_login_cookie(handler, user_id)
155-
# Record that we've been authenticated with a token.
156-
# Used in should_check_origin above.
159+
# Record that the current request has been authenticated with a token.
160+
# Used in is_token_authenticated above.
157161
handler._token_authenticated = True
158162
if user_id is None:
159163
# prevent extra Invalid cookie sig warnings:
@@ -169,7 +173,12 @@ def get_user(cls, handler):
169173

170174
@classmethod
171175
def get_user_token(cls, handler):
172-
"""Identify the user based on a token in the URL or Authorization header"""
176+
"""Identify the user based on a token in the URL or Authorization header
177+
178+
Returns:
179+
- uuid if authenticated
180+
- None if not
181+
"""
173182
token = handler.token
174183
if not token:
175184
return

notebook/base/handlers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def check_origin(self, origin_to_satisfy_tornado=""):
292292
host = self.request.headers.get("Host")
293293
origin = self.request.headers.get("Origin")
294294

295-
# If no header is provided, allow it.
295+
# If no header is provided, let the request through.
296296
# Origin can be None for:
297297
# - same-origin (IE, Firefox)
298298
# - Cross-site POST form (IE, Firefox)
@@ -323,7 +323,7 @@ def check_origin(self, origin_to_satisfy_tornado=""):
323323
return allow
324324

325325
def check_xsrf_cookie(self):
326-
"""Bypass xsrf checks when token-authenticated"""
326+
"""Bypass xsrf cookie checks when token-authenticated"""
327327
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

notebook/notebookapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def _token_changed(self, name, old, new):
567567
Jupyter notebook 4.3.1 introduces protection from cross-site request forgeries,
568568
requiring API requests to either:
569569
570-
- originate from the (validated with XSRF cookie and token), or
570+
- originate from pages served by this server (validated with XSRF cookie and token), or
571571
- authenticate with a token
572572
573573
Some anonymous compute resources still desire the ability to run code,

0 commit comments

Comments
 (0)