From f2f12ef0baeb4a6c941667fec7fd92dc4ea999bc Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 27 Oct 2021 15:21:52 +0200 Subject: [PATCH] api: fix error when connection to websocket via secret_key Signed-off-by: Jens Langhammer --- authentik/api/authentication.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/authentik/api/authentication.py b/authentik/api/authentication.py index 5f6b7b1f7..0b8fbe738 100644 --- a/authentik/api/authentication.py +++ b/authentik/api/authentication.py @@ -45,7 +45,8 @@ def bearer_auth(raw_header: bytes) -> Optional[User]: if not user: raise AuthenticationFailed("Token invalid/expired") return user - LOCAL.authentik[KEY_AUTH_VIA] = "api_token" + if hasattr(LOCAL, "authentik"): + LOCAL.authentik[KEY_AUTH_VIA] = "api_token" return tokens.first().user @@ -59,7 +60,8 @@ def token_secret_key(value: str) -> Optional[User]: outposts = Outpost.objects.filter(managed=MANAGED_OUTPOST) if not outposts: return None - LOCAL.authentik[KEY_AUTH_VIA] = "secret_key" + if hasattr(LOCAL, "authentik"): + LOCAL.authentik[KEY_AUTH_VIA] = "secret_key" outpost = outposts.first() return outpost.user