api: fix error when connection to websocket via secret_key

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-10-27 15:21:52 +02:00
parent 61d3df5f02
commit f2f12ef0ba
1 changed files with 4 additions and 2 deletions

View File

@ -45,7 +45,8 @@ def bearer_auth(raw_header: bytes) -> Optional[User]:
if not user: if not user:
raise AuthenticationFailed("Token invalid/expired") raise AuthenticationFailed("Token invalid/expired")
return user return user
LOCAL.authentik[KEY_AUTH_VIA] = "api_token" if hasattr(LOCAL, "authentik"):
LOCAL.authentik[KEY_AUTH_VIA] = "api_token"
return tokens.first().user return tokens.first().user
@ -59,7 +60,8 @@ def token_secret_key(value: str) -> Optional[User]:
outposts = Outpost.objects.filter(managed=MANAGED_OUTPOST) outposts = Outpost.objects.filter(managed=MANAGED_OUTPOST)
if not outposts: if not outposts:
return None return None
LOCAL.authentik[KEY_AUTH_VIA] = "secret_key" if hasattr(LOCAL, "authentik"):
LOCAL.authentik[KEY_AUTH_VIA] = "secret_key"
outpost = outposts.first() outpost = outposts.first()
return outpost.user return outpost.user