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

Hash cookie secret with user hashed password. #3009

Merged
merged 1 commit into from
Nov 3, 2017
Merged
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
14 changes: 10 additions & 4 deletions notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import time
import warnings
import webbrowser
import hmac

try: #PY3
from base64 import encodebytes
Expand Down Expand Up @@ -674,11 +675,16 @@ def _default_cookie_secret_file(self):
def _default_cookie_secret(self):
if os.path.exists(self.cookie_secret_file):
with io.open(self.cookie_secret_file, 'rb') as f:
return f.read()
key = f.read()
else:
secret = encodebytes(os.urandom(1024))
self._write_cookie_secret_file(secret)
return secret
key = encodebytes(os.urandom(1024))
self._write_cookie_secret_file(key)
h = hmac.HMAC(key)
h.digest_size = len(key)
h.update(self.password.encode())
return h.digest()



def _write_cookie_secret_file(self, secret):
"""write my secret to my secret_file"""
Expand Down