diff --git a/IPython/frontend/html/notebook/handlers.py b/IPython/frontend/html/notebook/handlers.py index 15d3561ae10..7822118c5d8 100644 --- a/IPython/frontend/html/notebook/handlers.py +++ b/IPython/frontend/html/notebook/handlers.py @@ -28,6 +28,7 @@ from IPython.external.decorator import decorator from IPython.zmq.session import Session +from IPython.lib.security import passwd_check try: from docutils.core import publish_string @@ -166,16 +167,25 @@ def get(self): class LoginHandler(AuthenticatedHandler): - def get(self): + def _render(self, message=''): self.render('login.html', next=self.get_argument('next', default='/'), read_only=self.read_only, + message=message ) + def get(self): + self._render() + def post(self): pwd = self.get_argument('password', default=u'') - if self.application.password and pwd == self.application.password: - self.set_secure_cookie('username', str(uuid.uuid4())) + if self.application.password: + if passwd_check(self.application.password, pwd): + self.set_secure_cookie('username', str(uuid.uuid4())) + else: + self._render(message='Invalid password') + return + self.redirect(self.get_argument('next', default='/')) diff --git a/IPython/frontend/html/notebook/notebookapp.py b/IPython/frontend/html/notebook/notebookapp.py index 6c4926952d0..157e856b5b1 100644 --- a/IPython/frontend/html/notebook/notebookapp.py +++ b/IPython/frontend/html/notebook/notebookapp.py @@ -208,7 +208,16 @@ def _ip_changed(self, name, old, new): ) password = Unicode(u'', config=True, - help="""Password to use for web authentication""" + help="""Hashed password to use for web authentication. + + To generate, do: + + from IPython.lib import passwd + + passwd('mypassphrase') + + The string should be of the form type:salt:hashed-password. + """ ) open_browser = Bool(True, config=True, diff --git a/IPython/frontend/html/notebook/static/css/layout.css b/IPython/frontend/html/notebook/static/css/layout.css index e80cca12e41..b9e0b086c3e 100644 --- a/IPython/frontend/html/notebook/static/css/layout.css +++ b/IPython/frontend/html/notebook/static/css/layout.css @@ -101,3 +101,15 @@ -moz-box-pack: center; box-pack: center; } + +#message { + border: 1px solid red; + background-color: #FFD3D1; + text-align: center; + padding: 0.5em; + margin: 0.5em; +} + +#content_panel { + margin: 0.5em; +} \ No newline at end of file diff --git a/IPython/frontend/html/notebook/static/css/projectdashboard.css b/IPython/frontend/html/notebook/static/css/projectdashboard.css index 9d730969deb..0ca74842f0b 100644 --- a/IPython/frontend/html/notebook/static/css/projectdashboard.css +++ b/IPython/frontend/html/notebook/static/css/projectdashboard.css @@ -31,7 +31,7 @@ body { } #content_toolbar { - padding: 10px 5px 5px 5px; + padding: 5px; height: 25px; line-height: 25px; } diff --git a/IPython/frontend/html/notebook/templates/login.html b/IPython/frontend/html/notebook/templates/login.html index 03b7b1c2490..b719c5b8816 100644 --- a/IPython/frontend/html/notebook/templates/login.html +++ b/IPython/frontend/html/notebook/templates/login.html @@ -31,6 +31,12 @@