Created
November 16, 2023 17:57
-
-
Save tsibley/4923761e0c527544874b54745b05d84a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
diff --git a/nextstrain/cli/authn.py b/nextstrain/cli/authn.py | |
index 93515ce..6cd2af0 100644 | |
--- a/nextstrain/cli/authn.py | |
+++ b/nextstrain/cli/authn.py | |
@@ -173,6 +173,26 @@ def logout(origin: Origin): | |
print(f"Not logged in to {origin}.", file = stderr) | |
+def logout_all(): | |
+ """ | |
+ XXX FIXME | |
+ """ | |
+ with config.write_lock(): | |
+ secrets = config.load(config.SECRETS) | |
+ | |
+ sections = [ | |
+ (section, _parse_section(section)) | |
+ for section in secrets | |
+ if _parse_section(section) ] | |
+ | |
+ for section, origin in sections: | |
+ del secrets[section] | |
+ print(f"Credentials for {origin} removed from {config.SECRETS}.", file = stderr) | |
+ print(f"Logged out of {origin}.", file = stderr) | |
+ | |
+ config.save(secrets, config.SECRETS) | |
+ | |
+ | |
def current_user(origin: Origin) -> Optional[User]: | |
""" | |
Information about the currently logged in user for *origin*, if any. | |
@@ -257,3 +265,12 @@ def _config_section(origin: Origin) -> str: | |
if origin == "https://nextstrain.org": | |
return CONFIG_SECTION | |
return f"{CONFIG_SECTION} {origin}" | |
+ | |
+ | |
+def _parse_section(section: str) -> Optional[Origin]: | |
+ if section == CONFIG_SECTION: | |
+ return Origin("https://nextstrain.org") | |
+ elif section.startswith(CONFIG_SECTION + " "): | |
+ return Origin(section.split(" ", 1)[1]) | |
+ else: | |
+ return None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment