From 195155fc7cfec18a4fcbd87382ca85b77d320f37 Mon Sep 17 00:00:00 2001 From: Georgiana Dolocan Date: Wed, 22 Mar 2023 16:06:15 +0200 Subject: [PATCH 1/2] Add support for binderhubs --- deployer/cilogon_app.py | 14 ++++++++++---- deployer/file_acquisition.py | 11 +++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/deployer/cilogon_app.py b/deployer/cilogon_app.py index 0e46190a72..75040d1f44 100644 --- a/deployer/cilogon_app.py +++ b/deployer/cilogon_app.py @@ -81,8 +81,10 @@ def persist_client_credentials_in_config_file(client, hub_type, config_filename) } } - if hub_type != "basehub": + if hub_type == "daskhub": auth_config["basehub"] = jupyterhub_config + elif hub_type == "hub_type": + auth_config["binderhub"] = jupyterhub_config else: auth_config = jupyterhub_config @@ -97,13 +99,17 @@ def load_client_id_from_file(config_filename): with open(decrypted_path) as f: auth_config = yaml.load(f) - basehub = auth_config.get("basehub", None) + daskhub = auth_config.get("basehub", None) + binderhub = auth_config.get("binderhub", None) try: - if basehub: + if daskhub: return auth_config["basehub"]["jupyterhub"]["hub"]["config"][ "CILogonOAuthenticator" ]["client_id"] - + elif binderhub: + return auth_config["binderhub"]["jupyterhub"]["hub"]["config"][ + "CILogonOAuthenticator" + ]["client_id"] return auth_config["jupyterhub"]["hub"]["config"]["CILogonOAuthenticator"][ "client_id" ] diff --git a/deployer/file_acquisition.py b/deployer/file_acquisition.py index 79dbb63f45..1810a39b6b 100644 --- a/deployer/file_acquisition.py +++ b/deployer/file_acquisition.py @@ -117,8 +117,8 @@ def persist_config_in_encrypted_file(encrypted_file, new_config): def remove_jupyterhub_hub_config_key_from_encrypted_file(encrypted_file, key): """ - Remove config from the dict `config["basehub"]["jupyterhub"]["hub"]["config"][key]` - in `encrypted_file` (the "basehub" key is optional). + Remove config from the dict `config["jupyterhub"]["hub"]["config"][]` + in `encrypted_file` (the config is also searched for under daskhub/binderhub prefixes). If after removing this config, the file only contains a config dict with empty leaves, delete the entire file, as it no longer holds any information. @@ -129,9 +129,12 @@ def remove_jupyterhub_hub_config_key_from_encrypted_file(encrypted_file, key): with open(decrypted_path) as f: config = yaml.load(f) - basehub = config.get("basehub", None) - if basehub: + daskhub = config.get("basehub", None) + binderhub = config.get("binderhub", None) + if daskhub: config["basehub"]["jupyterhub"]["hub"]["config"].pop(key) + elif binderhub: + config["binderhub"]["jupyterhub"]["hub"]["config"].pop(key) else: config["jupyterhub"]["hub"]["config"].pop(key) From 3457241b85f694b81dee90d68a2ebf3b9a81e747 Mon Sep 17 00:00:00 2001 From: Georgiana Dolocan Date: Wed, 22 Mar 2023 16:10:27 +0200 Subject: [PATCH 2/2] Fix type --- deployer/cilogon_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployer/cilogon_app.py b/deployer/cilogon_app.py index 75040d1f44..5befe81280 100644 --- a/deployer/cilogon_app.py +++ b/deployer/cilogon_app.py @@ -83,7 +83,7 @@ def persist_client_credentials_in_config_file(client, hub_type, config_filename) if hub_type == "daskhub": auth_config["basehub"] = jupyterhub_config - elif hub_type == "hub_type": + elif hub_type == "binderhub": auth_config["binderhub"] = jupyterhub_config else: auth_config = jupyterhub_config