Skip to content

Commit b0d0ed0

Browse files
committed
make cookie_secret configurable
allows config to specify logins that survive across server instances (default behavior unchanged). Depends on PR #3372
1 parent 78d5827 commit b0d0ed0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

IPython/frontend/html/notebook/notebookapp.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
from IPython.utils.localinterfaces import LOCALHOST
8484
from IPython.utils import submodule
8585
from IPython.utils.traitlets import (
86-
Dict, Unicode, Integer, List, Bool,
86+
Dict, Unicode, Integer, List, Bool, Bytes,
8787
DottedObjectName
8888
)
8989
from IPython.utils import py3compat
@@ -164,7 +164,7 @@ def init_settings(self, ipython_app, kernel_manager, notebook_manager,
164164
static_url_prefix = url_path_join(base_project_url,'/static/'),
165165

166166
# authentication
167-
cookie_secret=os.urandom(1024),
167+
cookie_secret=ipython_app.cookie_secret,
168168
login_url=url_path_join(base_project_url,'/login'),
169169
read_only=ipython_app.read_only,
170170
password=ipython_app.password,
@@ -338,6 +338,15 @@ def _ip_changed(self, name, old, new):
338338
keyfile = Unicode(u'', config=True,
339339
help="""The full path to a private key file for usage with SSL/TLS."""
340340
)
341+
342+
cookie_secret = Bytes(b'', config=True,
343+
help="""The random bytes used to secure cookies.
344+
By default this is a new random number every time you start the Notebook.
345+
Set it to a value in a config file to enable logins to persist across server sessions.
346+
"""
347+
)
348+
def _cookie_secret_default(self):
349+
return os.urandom(1024)
341350

342351
password = Unicode(u'', config=True,
343352
help="""Hashed password to use for web authentication.

0 commit comments

Comments
 (0)