Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set cookie on base_url #2959

Merged
merged 1 commit into from
Oct 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions notebook/auth/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def set_login_cookie(cls, handler, user_id=None):
# 'secure' kwarg is passed to set_secure_cookie
if handler.settings.get('secure_cookie', handler.request.protocol == 'https'):
cookie_options.setdefault('secure', True)
cookie_options.setdefault('path', handler.base_url)
handler.set_secure_cookie(handler.cookie_name, user_id, **cookie_options)
return user_id

Expand Down
12 changes: 9 additions & 3 deletions notebook/base/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,16 @@ def set_default_headers(self):
# if method is unsupported (websocket and Access-Control-Allow-Origin
# for example, so just ignore)
self.log.debug(e)

def clear_login_cookie(self):
self.clear_cookie(self.cookie_name)

cookie_options = self.settings.get('cookie_options', {})
path = cookie_options.setdefault('path', self.base_url)
self.clear_cookie(self.cookie_name, path=path)
if path and path != '/':
# also clear cookie on / to ensure old cookies
# are cleared after the change in path behavior.
self.clear_cookie(self.cookie_name)

def get_current_user(self):
if self.login_handler is None:
return 'anonymous'
Expand Down