-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jupyter URLs: add workaround for dynamic NERSC Shibboleth username
Signed-off-by: Lance-Drane <[email protected]>
- Loading branch information
1 parent
23b6e95
commit 6a2de79
Showing
4 changed files
with
50 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// in a URL for jupyter.nersc.gov , users must provide NERSC Shibboleth (auth manager) credentials in the URL, but this will only work for a single user. | ||
// We can dynamically create this URL on the frontend. | ||
|
||
const NERSC_URL_HELPER_STORAGE_KEY = "username__jupyter.nersc.gov"; | ||
|
||
function onJupyterUrlBtnClick() { | ||
const nersc_username = prompt( | ||
"Enter the username you authenticate with on NERSC Shibboleth.", | ||
window.localStorage.getItem(NERSC_URL_HELPER_STORAGE_KEY) || "" | ||
); | ||
if (nersc_username != null) { | ||
window.localStorage.setItem(NERSC_URL_HELPER_STORAGE_KEY, nersc_username); | ||
const result = jupyterUrlBtn | ||
.getAttribute("data-original-url") | ||
.replace(new RegExp("/user/[^/]+/"), `/user/${nersc_username}/`); | ||
window.location.href = result; | ||
} | ||
} | ||
|
||
for (jupyterUrlBtn of document.getElementsByClassName("jupyter-url-btn")) { | ||
jupyterUrlBtn.addEventListener("click", onJupyterUrlBtnClick); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters