Skip to content

Commit

Permalink
Fix auth issue
Browse files Browse the repository at this point in the history
  • Loading branch information
filippomc committed Dec 20, 2023
1 parent 960a096 commit a10859d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ def get_handlers(self, app):
'process_user': self.process_user
}
return [
('/chkclogin', CloudHarnessAuthenticateHandler, extra_settings),
('/nwbfile=.*', CloudHarnessAuthenticateHandler, extra_settings),
('/open=.*', CloudHarnessAuthenticateHandler, extra_settings),
('/query?.*', CloudHarnessAuthenticateHandler, extra_settings),
('.*', CloudHarnessAuthenticateHandler, extra_settings),
]

def login_url(self, base_url):
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .jupyterhub import change_pod_manifest
from .osb_jupyterhub import change_pod_manifest
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@
from cloudharness import applications
from cloudharness.auth.exceptions import UserNotFound
from urllib.parse import parse_qs, urlparse
from jupyterhub.handlers.pages import SpawnHandler

allowed_chars = set(
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

old_get = SpawnHandler.get

async def get(self, for_user=None, server_name=''):
print("get spawn", for_user, server_name)
return old_get(self, for_user=None, server_name=server_name)

SpawnHandler.get = get

def affinity_spec(key, value):
return {
Expand Down
15 changes: 2 additions & 13 deletions applications/jupyterlab-minimal/overrides/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">
<title>JupyterLab</title>
<meta name="viewport" content="width=device-width,initial-scale=1">{# Copy so we do not modify the page_config with
updates. #} {% set page_config_full = page_config.copy() %} {# Set a dummy variable - we just want the side effect
of the update. #} {% set _ = page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %}
<script id="jupyter-config-data" type="application/json">{{ page_config_full | tojson }}</script>{% block favicon %}
<link rel="icon" type="image/x-icon" href="{{ base_url | escape }}static/favicons/favicon.ico" class="idle favicon">
<link rel="" type="image/x-icon" href="{{ base_url | escape }}static/favicons/favicon-busy-1.ico" class="busy favicon">
{% endblock %}
<script defer="defer" src="{{page_config.fullStaticUrl}}/main.af1d2defcf4ce2e2e039.js?v=af1d2defcf4ce2e2e039"></script>
</head>
<head><meta charset="utf-8"><title>JupyterLab</title><meta name="viewport" content="width=device-width,initial-scale=1">{# Copy so we do not modify the page_config with updates. #} {% set page_config_full = page_config.copy() %} {# Set a dummy variable - we just want the side effect of the update. #} {% set _ = page_config_full.update(baseUrl=base_url, wsUrl=ws_url) %}<script id="jupyter-config-data" type="application/json">{{ page_config_full | tojson }}</script>{% block favicon %}<link rel="icon" type="image/x-icon" href="{{ base_url | escape }}static/favicons/favicon.ico" class="idle favicon"><link rel="" type="image/x-icon" href="{{ base_url | escape }}static/favicons/favicon-busy-1.ico" class="busy favicon">{% endblock %}<script defer="defer" src="{{page_config.fullStaticUrl}}/main.006c51afc5ba8822ed23.js?v=006c51afc5ba8822ed23"></script></head>

<body>
<script>/* Remove token from URL. */
Expand All @@ -32,7 +21,7 @@
console.debug("Load resource", event.data);
const relativeResourcePath = event.data.payload.replace("/opt/workspace/", "")
if (!window.location.href.includes(relativeResourcePath)) {
window.location.href = window.location.href.split("lab")[0] + `lab/tree/${relativeResourcePath}`;
window.location.href = window.location.href.split("/lab")[0] + `/lab/tree/${relativeResourcePath}`;
}
break;
case "NO_RESOURCE": {
Expand Down
2 changes: 1 addition & 1 deletion applications/osb-portal/deploy/values-minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ harness:
- workspaces
- jupyterhub
- notifications
- jupyterlab
- jupyterlab-minimal

Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,14 @@ export const WorkspaceFrame = (props: {
const userParam = user == null ? "" : `${user.id}`;
const type = application.subdomain.slice(0, 4);
document.cookie = `workspaceId=${workspace.id};path=/;domain=${domain}`;
if(applicationDomain) {
fetch(`//${applicationDomain}/hub/logout`).then(() => {
setFrameUrl(`//${applicationDomain}/hub/spawn/${userParam}/${workspace.id}${type}${document.location.search ?? ''}`);
});
} else {
setFrameUrl(`/testapp?workspaceId=${workspace.id}&type=${type}&user=${userParam}&application=${application.name}`);
}

setFrameUrl(applicationDomain ? `//${applicationDomain}/hub/spawn/${userParam}/${workspace.id}${type}${document.location.search ?? ''}`: `/testapp?workspaceId=${workspace.id}&type=${type}&user=${userParam}&application=${application.name}`);
}, [application]);

const openResource = async () => {
Expand Down

0 comments on commit a10859d

Please sign in to comment.