From 58a4b20297315d482fd9536d8f4dde3049e5c8d6 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 25 May 2021 11:46:28 +0200 Subject: [PATCH] outposts: handle disconnects without outpost better Signed-off-by: Jens Langhammer --- authentik/outposts/channels.py | 5 ++++- authentik/providers/oauth2/views/userinfo.py | 9 ++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/authentik/outposts/channels.py b/authentik/outposts/channels.py index 3e46dceed..f4794de12 100644 --- a/authentik/outposts/channels.py +++ b/authentik/outposts/channels.py @@ -50,7 +50,7 @@ class WebsocketMessage: class OutpostConsumer(AuthJsonConsumer): """Handler for Outposts that connect over websockets for health checks and live updates""" - outpost: Outpost + outpost: Optional[Outpost] = None last_uid: Optional[str] = None @@ -95,6 +95,9 @@ class OutpostConsumer(AuthJsonConsumer): uid = msg.args.get("uuid", self.channel_name) self.last_uid = uid + if not self.outpost: + raise DenyConnection() + state = OutpostState.for_instance_uid(self.outpost, uid) if self.channel_name not in state.channel_ids: state.channel_ids.append(self.channel_name) diff --git a/authentik/providers/oauth2/views/userinfo.py b/authentik/providers/oauth2/views/userinfo.py index 75f5135dd..0771c3313 100644 --- a/authentik/providers/oauth2/views/userinfo.py +++ b/authentik/providers/oauth2/views/userinfo.py @@ -3,7 +3,6 @@ from typing import Any, Optional from django.http import HttpRequest, HttpResponse from django.http.response import HttpResponseBadRequest -from django.utils.translation import gettext_lazy as _ from django.views import View from structlog.stdlib import get_logger @@ -38,14 +37,14 @@ class UserInfoView(View): # GitHub Compatibility Scopes are handeled differently, since they required custom paths # Hence they don't exist as Scope objects github_scope_map = { - SCOPE_GITHUB_USER: _("GitHub Compatibility: Access your User Information"), - SCOPE_GITHUB_USER_READ: _( + SCOPE_GITHUB_USER: ("GitHub Compatibility: Access your User Information"), + SCOPE_GITHUB_USER_READ: ( "GitHub Compatibility: Access your User Information" ), - SCOPE_GITHUB_USER_EMAIL: _( + SCOPE_GITHUB_USER_EMAIL: ( "GitHub Compatibility: Access you Email addresses" ), - SCOPE_GITHUB_ORG_READ: _("GitHub Compatibility: Access your Groups"), + SCOPE_GITHUB_ORG_READ: ("GitHub Compatibility: Access your Groups"), } for scope in scopes: if scope in github_scope_map: