Show More
@@ -1,24 +1,28 b'' | |||||
1 | """Tornado handlers for the terminal emulator.""" |
|
1 | """Tornado handlers for the terminal emulator.""" | |
2 |
|
2 | |||
3 | # Copyright (c) IPython Development Team. |
|
3 | # Copyright (c) IPython Development Team. | |
4 | # Distributed under the terms of the Modified BSD License. |
|
4 | # Distributed under the terms of the Modified BSD License. | |
5 |
|
5 | |||
6 | from tornado import web |
|
6 | from tornado import web | |
7 | import terminado |
|
7 | import terminado | |
8 | from ..base.handlers import IPythonHandler |
|
8 | from ..base.handlers import IPythonHandler | |
9 |
|
9 | |||
10 | class TerminalHandler(IPythonHandler): |
|
10 | class TerminalHandler(IPythonHandler): | |
11 | """Render the terminal interface.""" |
|
11 | """Render the terminal interface.""" | |
12 | @web.authenticated |
|
12 | @web.authenticated | |
13 | def get(self, term_name): |
|
13 | def get(self, term_name): | |
14 | self.write(self.render_template('terminal.html', |
|
14 | self.write(self.render_template('terminal.html', | |
15 | ws_path="terminals/websocket/%s" % term_name)) |
|
15 | ws_path="terminals/websocket/%s" % term_name)) | |
16 |
|
16 | |||
17 | class NewTerminalHandler(IPythonHandler): |
|
17 | class NewTerminalHandler(IPythonHandler): | |
18 | """Redirect to a new terminal.""" |
|
18 | """Redirect to a new terminal.""" | |
19 | @web.authenticated |
|
19 | @web.authenticated | |
20 | def get(self): |
|
20 | def get(self): | |
21 | name, _ = self.application.terminal_manager.new_named_terminal() |
|
21 | name, _ = self.application.terminal_manager.new_named_terminal() | |
22 | self.redirect("/terminals/%s" % name, permanent=False) |
|
22 | self.redirect("/terminals/%s" % name, permanent=False) | |
23 |
|
23 | |||
24 |
TermSocket |
|
24 | class TermSocket(terminado.TermSocket, IPythonHandler): | |
|
25 | def get(self, *args, **kwargs): | |||
|
26 | if not self.get_current_user(): | |||
|
27 | raise web.HTTPError(403) | |||
|
28 | return super(TermSocket, self).get(*args, **kwargs) |
General Comments 0
You need to be logged in to leave comments.
Login now