From e15ba88b077f3985507e1fff77a08278431131ff Mon Sep 17 00:00:00 2001 From: Anastasiia Sliusar Date: Mon, 12 Aug 2024 12:16:35 +0200 Subject: [PATCH 1/5] Add allow_insecure_kernelspec_params to page config --- jupyterlab_server/handlers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jupyterlab_server/handlers.py b/jupyterlab_server/handlers.py index 79df953..0641110 100644 --- a/jupyterlab_server/handlers.py +++ b/jupyterlab_server/handlers.py @@ -82,6 +82,8 @@ def get_page_config(self) -> dict[str, Any]: server_root = self.settings.get("server_root_dir", "") server_root = server_root.replace(os.sep, "/") base_url = self.settings.get("base_url") + server_app = self.settings.get("serverapp") + allow_insecure_kernelspec_params = server_app.allow_insecure_kernelspec_params # Remove the trailing slash for compatibility with html-webpack-plugin. full_static_url = self.static_url_prefix.rstrip("/") @@ -91,6 +93,7 @@ def get_page_config(self) -> dict[str, Any]: page_config.setdefault("ignorePlugins", []) page_config.setdefault("serverRoot", server_root) page_config["store_id"] = self.application.store_id # type:ignore[attr-defined] + page_config.setdefault("allow_insecure_kernelspec_params", allow_insecure_kernelspec_params) server_root = os.path.normpath(os.path.expanduser(server_root)) preferred_path = "" From 01971335995ce2082a2fb366ac58b7750c72ed70 Mon Sep 17 00:00:00 2001 From: Anastasiia Sliusar Date: Wed, 14 Aug 2024 14:29:51 +0200 Subject: [PATCH 2/5] Fix linting --- jupyterlab_server/handlers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jupyterlab_server/handlers.py b/jupyterlab_server/handlers.py index 0641110..d442a5a 100644 --- a/jupyterlab_server/handlers.py +++ b/jupyterlab_server/handlers.py @@ -83,7 +83,9 @@ def get_page_config(self) -> dict[str, Any]: server_root = server_root.replace(os.sep, "/") base_url = self.settings.get("base_url") server_app = self.settings.get("serverapp") - allow_insecure_kernelspec_params = server_app.allow_insecure_kernelspec_params + assert server_app is not None + if server_app.allow_insecure_kernelspec_params: + allow_insecure_kernelspec_params = server_app.allow_insecure_kernelspec_params # Remove the trailing slash for compatibility with html-webpack-plugin. full_static_url = self.static_url_prefix.rstrip("/") From f6d4a9431f4d3b0359feb0b826f8c1421a4666d9 Mon Sep 17 00:00:00 2001 From: Anastasiia Sliusar Date: Wed, 14 Aug 2024 14:35:47 +0200 Subject: [PATCH 3/5] Fix condition --- jupyterlab_server/handlers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jupyterlab_server/handlers.py b/jupyterlab_server/handlers.py index d442a5a..de95c17 100644 --- a/jupyterlab_server/handlers.py +++ b/jupyterlab_server/handlers.py @@ -86,6 +86,8 @@ def get_page_config(self) -> dict[str, Any]: assert server_app is not None if server_app.allow_insecure_kernelspec_params: allow_insecure_kernelspec_params = server_app.allow_insecure_kernelspec_params + else: + allow_insecure_kernelspec_params = False # Remove the trailing slash for compatibility with html-webpack-plugin. full_static_url = self.static_url_prefix.rstrip("/") From 229e2cb9f2fbcb8c4b865c6da90f7ca3b5b2a732 Mon Sep 17 00:00:00 2001 From: Anastasiia Sliusar Date: Wed, 14 Aug 2024 16:51:38 +0200 Subject: [PATCH 4/5] Update test_page_config test --- jupyterlab_server/handlers.py | 2 +- tests/test_labapp.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/jupyterlab_server/handlers.py b/jupyterlab_server/handlers.py index de95c17..36ffa5f 100644 --- a/jupyterlab_server/handlers.py +++ b/jupyterlab_server/handlers.py @@ -84,7 +84,7 @@ def get_page_config(self) -> dict[str, Any]: base_url = self.settings.get("base_url") server_app = self.settings.get("serverapp") assert server_app is not None - if server_app.allow_insecure_kernelspec_params: + if hasattr(server_app, 'allow_insecure_kernelspec_params'): allow_insecure_kernelspec_params = server_app.allow_insecure_kernelspec_params else: allow_insecure_kernelspec_params = False diff --git a/tests/test_labapp.py b/tests/test_labapp.py index d7e39dd..9a2c17e 100644 --- a/tests/test_labapp.py +++ b/tests/test_labapp.py @@ -60,6 +60,7 @@ def ispath(p): nondirs = {k: v for k, v in page_config.items() if not ispath(k)} assert nondirs == { + "allow_insecure_kernelspec_params": False, "appName": "JupyterLab Server Application", "appNamespace": "jupyterlab_server", "appUrl": "/lab", From 16a113d9782784aa40f42737f62c5a3f8f727b3b Mon Sep 17 00:00:00 2001 From: Anastasiia Sliusar Date: Wed, 14 Aug 2024 16:52:25 +0200 Subject: [PATCH 5/5] Fix lint --- jupyterlab_server/handlers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jupyterlab_server/handlers.py b/jupyterlab_server/handlers.py index 36ffa5f..ca95e73 100644 --- a/jupyterlab_server/handlers.py +++ b/jupyterlab_server/handlers.py @@ -84,7 +84,7 @@ def get_page_config(self) -> dict[str, Any]: base_url = self.settings.get("base_url") server_app = self.settings.get("serverapp") assert server_app is not None - if hasattr(server_app, 'allow_insecure_kernelspec_params'): + if hasattr(server_app, "allow_insecure_kernelspec_params"): allow_insecure_kernelspec_params = server_app.allow_insecure_kernelspec_params else: allow_insecure_kernelspec_params = False