8000 Merge pull request #3321 from ellisonbg/nbreorg · ipython/ipython@fbaab3a · GitHub
[go: up one dir, main page]

Skip to content

Commit fbaab3a

Browse files
committed
Merge pull request #3321 from ellisonbg/nbreorg
Reorganize the python/server side of the notebook
2 parents 831d4eb + 83cf0e6 commit fbaab3a

34 files changed

+1304
-1000
lines changed

IPython/frontend/html/notebook/auth/__init__.py

Whitespace-only changes.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"""Tornado handlers logging into the notebook.
2+
3+
Authors:
4+
5+
* Brian Granger
6+
"""
7+
8+
#-----------------------------------------------------------------------------
9+
# Copyright (C) 2011 The IPython Development Team
10+
#
11+
# Distributed under the terms of the BSD License. The full license is in
12+
# the file COPYING, distributed as part of this software.
13+
#-----------------------------------------------------------------------------
14+
15+
#-----------------------------------------------------------------------------
16+
# Imports
17+
#-----------------------------------------------------------------------------
18+
19+
import uuid
20+
21+
from tornado.escape import url_escape
22+
23+
from IPython.lib.security import passwd_check
24+
25+
from ..base.handlers import IPythonHandler
26+
27+
#-----------------------------------------------------------------------------
28+
# Handler
29+
#-----------------------------------------------------------------------------
30+
31+
class LoginHandler(IPythonHandler):
32+
33+
def _render(self, message=None):
34+
self.write(self.render_template('login.html',
35+
next=url_escape(self.get_argument('next', default=self.base_project_url)),
36+
message=message,
37+
))
38+
39+
def get(self):
40+
if self.current_user:
41+
self.redirect(self.get_argument('next', default=self.base_project_url))
42+
else:
43+
self._render()
44+
45+
def post(self):
46+
pwd = self.get_argument('password', default=u'')
47+
if self.login_available:
48+
if passwd_check(self.password, pwd):
49+
self.set_secure_cookie(self.cookie_name, str(uuid.uuid4()))
50+
else:
51+
self._render(message={'error': 'Invalid password'})
52+
return
53+
54+
self.redirect(self.get_argument('next', default=self.base_project_url))
55+
56+
57+
#-----------------------------------------------------------------------------
58+
# URL to handler mappings
59+
#-----------------------------------------------------------------------------
60+
61+
62+
default_handlers = [(r"/login", LoginHandler)]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""Tornado handlers for logging out of the notebook.
2+
3+
Authors:
4+
5+
* Brian Granger
6+
"""
7+
8+
#-----------------------------------------------------------------------------
9+
# Copyright (C) 2011 The IPython Development Team
10+
#
11+
# Distributed under the terms of the BSD License. The full license is in
12+
# the file COPYING, distributed as part of this software.
13+
#-----------------------------------------------------------------------------
14+
15+
#-----------------------------------------------------------------------------
16+
# Imports
17+
#-----------------------------------------------------------------------------
18+
19+
from ..base.handlers import IPythonHandler
20+
21+
#-----------------------------------------------------------------------------
22+
# Handler
23+
#-----------------------------------------------------------------------------
24+
25+
26+
class LogoutHandler(IPythonHandler):
27+
28+
def get(self):
29+
self.clear_login_cookie()
30+
if self.login_available:
31+
message = {'info': 'Successfully logged out.'}
32+
else:
33+
message = {'warning': 'Cannot log out. Notebook authentication '
34+
'is disabled.'}
35+
self.write(self.render_template('logout.html',
36+
message=message))
37+
38+
39+
#-----------------------------------------------------------------------------
40+
# URL to handler mappings
41+
#-----------------------------------------------------------------------------
42+
43+
44+
default_handlers = [(r"/logout", LogoutHandler)]

IPython/frontend/html/notebook/base/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)
0