From 65be593c6b16d69009a6d026d92681bdff7c8be0 Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Tue, 24 Aug 2021 16:05:06 +0100 Subject: [PATCH] authenticate the static handler * Closes #231 * Provide our own static handler rather than using Jupyter Server. * This is because we are not using the same template/static resource approach. * We would have to edit URLs in the UI to point at `static/cylc/*`. * Adding authentication here provides login redirection. --- cylc/uiserver/handlers.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cylc/uiserver/handlers.py b/cylc/uiserver/handlers.py index 8aa021b9..4e05ffb6 100644 --- a/cylc/uiserver/handlers.py +++ b/cylc/uiserver/handlers.py @@ -151,7 +151,12 @@ def hub_groups(self): class CylcStaticHandler(CylcAppHandler, web.StaticFileHandler): - pass + + @web.authenticated + def get(self, path): + # authenticate the static handler + # this provides us with login redirection and token cashing + return web.StaticFileHandler.get(self, path) class UserProfileHandler(CylcAppHandler):