Show More
@@ -0,0 +1,58 b'' | |||||
|
1 | <!DOCTYPE HTML> | |||
|
2 | <html> | |||
|
3 | ||||
|
4 | <head> | |||
|
5 | <meta charset="utf-8"> | |||
|
6 | ||||
|
7 | <title>IPython Notebook</title> | |||
|
8 | ||||
|
9 | <link rel="stylesheet" href="static/jquery/css/themes/aristo/jquery-wijmo.css" type="text/css" /> | |||
|
10 | <!-- <link rel="stylesheet" href="static/jquery/css/themes/rocket/jquery-wijmo.css" type="text/css" /> --> | |||
|
11 | <!-- <link rel="stylesheet" href="static/jquery/css/themes/smoothness/jquery-ui-1.8.14.custom.css" type="text/css" />--> | |||
|
12 | ||||
|
13 | <link rel="stylesheet" href="static/css/boilerplate.css" type="text/css" /> | |||
|
14 | <link rel="stylesheet" href="static/css/layout.css" type="text/css" /> | |||
|
15 | <link rel="stylesheet" href="static/css/base.css" type="text/css" /> | |||
|
16 | ||||
|
17 | </head> | |||
|
18 | ||||
|
19 | <body> | |||
|
20 | ||||
|
21 | <div id="header"> | |||
|
22 | <span id="ipython_notebook"><h1>IPython Notebook</h1></span> | |||
|
23 | </div> | |||
|
24 | ||||
|
25 | <div id="header_border"></div> | |||
|
26 | ||||
|
27 | <div id="main_app"> | |||
|
28 | ||||
|
29 | <div id="app_hbox"> | |||
|
30 | ||||
|
31 | <div id="left_panel"> | |||
|
32 | </div> | |||
|
33 | ||||
|
34 | <div id="content_panel"> | |||
|
35 | <form action="/login" method="post"> | |||
|
36 | Name: <input type="text" name="name" value="{{user_id}}"> | |||
|
37 | Password: <input type="password" name="password"> | |||
|
38 | <input type="submit" value="Sign in"> | |||
|
39 | </form> | |||
|
40 | </div> | |||
|
41 | <div id="right_panel"> | |||
|
42 | </div> | |||
|
43 | ||||
|
44 | </div> | |||
|
45 | ||||
|
46 | </div> | |||
|
47 | ||||
|
48 | <script src="static/jquery/js/jquery-1.6.2.min.js" type="text/javascript" charset="utf-8"></script> | |||
|
49 | <script src="static/jquery/js/jquery-ui-1.8.14.custom.min.js" type="text/javascript" charset="utf-8"></script> | |||
|
50 | <script src="static/js/namespace.js" type="text/javascript" charset="utf-8"></script> | |||
|
51 | <script src="static/js/notebooklist.js" type="text/javascript" charset="utf-8"></script> | |||
|
52 | <script src="static/js/nbbrowser_main.js" type="text/javascript" charset="utf-8"></script> | |||
|
53 | ||||
|
54 | </body> | |||
|
55 | ||||
|
56 | </html> | |||
|
57 | ||||
|
58 |
@@ -38,8 +38,11 b' except ImportError:' | |||||
38 | class BaseHandler(web.RequestHandler): |
|
38 | class BaseHandler(web.RequestHandler): | |
39 | def get_current_user(self): |
|
39 | def get_current_user(self): | |
40 | user_id = self.get_secure_cookie("user") |
|
40 | user_id = self.get_secure_cookie("user") | |
41 | keyword = self.get_secure_cookie("keyword") |
|
41 | if user_id is None: | |
42 | if self.application.keyword and self.application.keyword != keyword: |
|
42 | self.clear_cookie('user') | |
|
43 | self.clear_cookie('password') | |||
|
44 | password = self.get_secure_cookie("password") | |||
|
45 | if self.application.password and self.application.password != password: | |||
43 | return None |
|
46 | return None | |
44 | if not user_id: |
|
47 | if not user_id: | |
45 | user_id = 'anonymous' |
|
48 | user_id = 'anonymous' | |
@@ -55,15 +58,16 b' class NBBrowserHandler(BaseHandler):' | |||||
55 | class LoginHandler(BaseHandler): |
|
58 | class LoginHandler(BaseHandler): | |
56 | def get(self): |
|
59 | def get(self): | |
57 | user_id = self.get_secure_cookie("user") |
|
60 | user_id = self.get_secure_cookie("user") | |
58 | self.write('<html><body><form action="/login" method="post">' |
|
61 | if user_id is None: | |
59 | 'Name: <input type="text" name="name" value=%s>' |
|
62 | self.clear_cookie('user') | |
60 | 'Keyword: <input type="password" name="keyword">' |
|
63 | self.clear_cookie('password') | |
61 | '<input type="submit" value="Sign in">' |
|
64 | user_id = '' | |
62 | '</form></body></html>'%user_id) |
|
65 | ||
|
66 | self.render('login.html', user_id=user_id) | |||
63 |
|
67 | |||
64 | def post(self): |
|
68 | def post(self): | |
65 | self.set_secure_cookie("user", self.get_argument("name", default=u'')) |
|
69 | self.set_secure_cookie("user", self.get_argument("name", default=u'')) | |
66 |
self.set_secure_cookie(" |
|
70 | self.set_secure_cookie("password", self.get_argument("password", default=u'')) | |
67 | self.redirect("/") |
|
71 | self.redirect("/") | |
68 |
|
72 | |||
69 | class NewHandler(web.RequestHandler): |
|
73 | class NewHandler(web.RequestHandler): |
@@ -95,7 +95,7 b' class NotebookWebApplication(web.Application):' | |||||
95 | settings = dict( |
|
95 | settings = dict( | |
96 | template_path=os.path.join(os.path.dirname(__file__), "templates"), |
|
96 | template_path=os.path.join(os.path.dirname(__file__), "templates"), | |
97 | static_path=os.path.join(os.path.dirname(__file__), "static"), |
|
97 | static_path=os.path.join(os.path.dirname(__file__), "static"), | |
98 | cookie_secret="61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=", |
|
98 | cookie_secret=os.urandom(1024), | |
99 | login_url="/login", |
|
99 | login_url="/login", | |
100 | ) |
|
100 | ) | |
101 | web.Application.__init__(self, handlers, **settings) |
|
101 | web.Application.__init__(self, handlers, **settings) | |
@@ -126,11 +126,10 b' aliases.update({' | |||||
126 | 'certfile': 'IPythonNotebookApp.certfile', |
|
126 | 'certfile': 'IPythonNotebookApp.certfile', | |
127 | 'ws-hostname': 'IPythonNotebookApp.ws_hostname', |
|
127 | 'ws-hostname': 'IPythonNotebookApp.ws_hostname', | |
128 | 'notebook-dir': 'NotebookManager.notebook_dir', |
|
128 | 'notebook-dir': 'NotebookManager.notebook_dir', | |
129 | 'keyword' : 'IPythonNotebookApp.keyword' |
|
|||
130 | }) |
|
129 | }) | |
131 |
|
130 | |||
132 | notebook_aliases = [u'port', u'ip', u'keyfile', u'certfile', u'ws-hostname', |
|
131 | notebook_aliases = [u'port', u'ip', u'keyfile', u'certfile', u'ws-hostname', | |
133 |
u'notebook-dir' |
|
132 | u'notebook-dir'] | |
134 |
|
133 | |||
135 | #----------------------------------------------------------------------------- |
|
134 | #----------------------------------------------------------------------------- | |
136 | # IPythonNotebookApp |
|
135 | # IPythonNotebookApp | |
@@ -189,8 +188,8 b' class IPythonNotebookApp(BaseIPythonApplication):' | |||||
189 | help="""The full path to a private key file for usage with SSL/TLS.""" |
|
188 | help="""The full path to a private key file for usage with SSL/TLS.""" | |
190 | ) |
|
189 | ) | |
191 |
|
190 | |||
192 |
|
|
191 | password = Unicode(u'', config=True, | |
193 |
help=""" |
|
192 | help="""Password to use for web authentication""" | |
194 | ) |
|
193 | ) | |
195 |
|
194 | |||
196 | def get_ws_url(self): |
|
195 | def get_ws_url(self): | |
@@ -249,7 +248,7 b' class IPythonNotebookApp(BaseIPythonApplication):' | |||||
249 | ssl_options['keyfile'] = self.keyfile |
|
248 | ssl_options['keyfile'] = self.keyfile | |
250 | else: |
|
249 | else: | |
251 | ssl_options = None |
|
250 | ssl_options = None | |
252 |
self.web_app. |
|
251 | self.web_app.password = self.password | |
253 | self.http_server = httpserver.HTTPServer(self.web_app, ssl_options=ssl_options) |
|
252 | self.http_server = httpserver.HTTPServer(self.web_app, ssl_options=ssl_options) | |
254 | if ssl_options is None and not self.ip: |
|
253 | if ssl_options is None and not self.ip: | |
255 | self.log.critical('WARNING: the notebook server is listening on all IP addresses ' |
|
254 | self.log.critical('WARNING: the notebook server is listening on all IP addresses ' |
General Comments 0
You need to be logged in to leave comments.
Login now