##// END OF EJS Templates
authenticate local file access...
MinRK -
Show More
@@ -107,6 +107,7 b' def authenticate_unless_readonly(f, self, *args, **kwargs):'
107 @web.authenticated
107 @web.authenticated
108 def auth_f(self, *args, **kwargs):
108 def auth_f(self, *args, **kwargs):
109 return f(self, *args, **kwargs)
109 return f(self, *args, **kwargs)
110
110 if self.application.read_only:
111 if self.application.read_only:
111 return f(self, *args, **kwargs)
112 return f(self, *args, **kwargs)
112 else:
113 else:
@@ -174,6 +175,14 b' class AuthenticatedHandler(RequestHandler):'
174 return "%s://%s" % (proto, self.request.host)
175 return "%s://%s" % (proto, self.request.host)
175
176
176
177
178 class AuthenticatedFileHandler(AuthenticatedHandler, web.StaticFileHandler):
179 """static files should only be accessible when logged in"""
180
181 @authenticate_unless_readonly
182 def get(self, path):
183 return web.StaticFileHandler.get(self, path)
184
185
177 class ProjectDashboardHandler(AuthenticatedHandler):
186 class ProjectDashboardHandler(AuthenticatedHandler):
178
187
179 @authenticate_unless_readonly
188 @authenticate_unless_readonly
@@ -48,7 +48,8 b' from .kernelmanager import MappingKernelManager'
48 from .handlers import (LoginHandler, LogoutHandler,
48 from .handlers import (LoginHandler, LogoutHandler,
49 ProjectDashboardHandler, NewHandler, NamedNotebookHandler,
49 ProjectDashboardHandler, NewHandler, NamedNotebookHandler,
50 MainKernelHandler, KernelHandler, KernelActionHandler, IOPubHandler,
50 MainKernelHandler, KernelHandler, KernelActionHandler, IOPubHandler,
51 ShellHandler, NotebookRootHandler, NotebookHandler, RSTHandler
51 ShellHandler, NotebookRootHandler, NotebookHandler, RSTHandler,
52 AuthenticatedFileHandler,
52 )
53 )
53 from .notebookmanager import NotebookManager
54 from .notebookmanager import NotebookManager
54
55
@@ -104,7 +105,7 b' class NotebookWebApplication(web.Application):'
104 (r"/notebooks", NotebookRootHandler),
105 (r"/notebooks", NotebookRootHandler),
105 (r"/notebooks/%s" % _notebook_id_regex, NotebookHandler),
106 (r"/notebooks/%s" % _notebook_id_regex, NotebookHandler),
106 (r"/rstservice/render", RSTHandler),
107 (r"/rstservice/render", RSTHandler),
107 (r"/local/(.*)", web.StaticFileHandler, {'path' : notebook_manager.notebook_dir}),
108 (r"/local/(.*)", AuthenticatedFileHandler, {'path' : notebook_manager.notebook_dir}),
108 ]
109 ]
109 settings = dict(
110 settings = dict(
110 template_path=os.path.join(os.path.dirname(__file__), "templates"),
111 template_path=os.path.join(os.path.dirname(__file__), "templates"),
General Comments 0
You need to be logged in to leave comments. Login now