From 9cbb8042874f60dafe812527d923d13664782b21 Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Tue, 3 Oct 2023 15:18:50 -0700 Subject: [PATCH] authn: Handle case when a user is not in any group In this case, the "cognito:groups" claim does not exist. Previously, this resulted in a KeyError upon login and whoami commands. --- nextstrain/cli/authn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nextstrain/cli/authn.py b/nextstrain/cli/authn.py index 95251caa..e8ab655a 100644 --- a/nextstrain/cli/authn.py +++ b/nextstrain/cli/authn.py @@ -48,7 +48,7 @@ def __init__(self, session: cognito.Session): assert session.id_claims self.username = session.id_claims["cognito:username"] - self.groups = session.id_claims["cognito:groups"] + self.groups = session.id_claims.get("cognito:groups", []) self.email = session.id_claims["email"] self.http_authorization = f"Bearer {session.id_token}"