Skip to content

Commit

Permalink
Merge pull request #2407 from GeorgianaElena/cilogon-app-binderhub-su…
Browse files Browse the repository at this point in the history
…pport

deployer: Add support for binderhubs in the cilogon_app script
  • Loading branch information
GeorgianaElena authored Mar 23, 2023
2 parents 8b0e79d + 3457241 commit 2e08927
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
14 changes: 10 additions & 4 deletions deployer/cilogon_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "binderhub":
auth_config["binderhub"] = jupyterhub_config
else:
auth_config = jupyterhub_config

Expand All @@ -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"
]
Expand Down
11 changes: 7 additions & 4 deletions deployer/file_acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"][<key>]`
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.
Expand All @@ -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)

Expand Down

0 comments on commit 2e08927

Please sign in to comment.