From 32c5bf04b80ec582350becdb4458906c82509729 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 17 Apr 2021 20:08:49 +0200 Subject: [PATCH] *: fix linting errors Signed-off-by: Jens Langhammer --- authentik/core/api/propertymappings.py | 2 +- authentik/core/api/providers.py | 2 +- authentik/core/api/sources.py | 2 +- authentik/events/api/event.py | 7 +------ authentik/flows/api/stages.py | 2 +- authentik/outposts/api/outpost_service_connections.py | 2 +- authentik/policies/api/policies.py | 2 +- authentik/providers/oauth2/views/authorize.py | 5 ++++- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/authentik/core/api/propertymappings.py b/authentik/core/api/propertymappings.py index 88231c76a..56d3cded5 100644 --- a/authentik/core/api/propertymappings.py +++ b/authentik/core/api/propertymappings.py @@ -93,7 +93,7 @@ class PropertyMappingViewSet( "description": subclass.__doc__, # pyright: reportGeneralTypeIssues=false "component": subclass().component, - "model_name": subclass._meta.model_name + "model_name": subclass._meta.model_name, } ) return Response(TypeCreateSerializer(data, many=True).data) diff --git a/authentik/core/api/providers.py b/authentik/core/api/providers.py index 366e216a4..f4f8ec22d 100644 --- a/authentik/core/api/providers.py +++ b/authentik/core/api/providers.py @@ -78,7 +78,7 @@ class ProviderViewSet( "name": subclass._meta.verbose_name, "description": subclass.__doc__, "component": subclass().component, - "model_name": subclass._meta.model_name + "model_name": subclass._meta.model_name, } ) data.append( diff --git a/authentik/core/api/sources.py b/authentik/core/api/sources.py index cef9493e8..a9c481a07 100644 --- a/authentik/core/api/sources.py +++ b/authentik/core/api/sources.py @@ -81,7 +81,7 @@ class SourceViewSet( "name": subclass._meta.verbose_name, "description": subclass.__doc__, "component": component, - "model_name": subclass._meta.model_name + "model_name": subclass._meta.model_name, } ) return Response(TypeCreateSerializer(data, many=True).data) diff --git a/authentik/events/api/event.py b/authentik/events/api/event.py index 135aedb4d..2134da380 100644 --- a/authentik/events/api/event.py +++ b/authentik/events/api/event.py @@ -153,11 +153,6 @@ class EventViewSet(ReadOnlyModelViewSet): data = [] for value, name in EventAction.choices: data.append( - { - "name": name, - "description": "", - "component": value, - "model_name": "" - } + {"name": name, "description": "", "component": value, "model_name": ""} ) return Response(TypeCreateSerializer(data, many=True).data) diff --git a/authentik/flows/api/stages.py b/authentik/flows/api/stages.py index 1e528c282..749e4a7ac 100644 --- a/authentik/flows/api/stages.py +++ b/authentik/flows/api/stages.py @@ -80,7 +80,7 @@ class StageViewSet( "name": subclass._meta.verbose_name, "description": subclass.__doc__, "component": subclass().component, - "model_name": subclass._meta.model_name + "model_name": subclass._meta.model_name, } ) data = sorted(data, key=lambda x: x["name"]) diff --git a/authentik/outposts/api/outpost_service_connections.py b/authentik/outposts/api/outpost_service_connections.py index 2aea17531..39b54c1e5 100644 --- a/authentik/outposts/api/outpost_service_connections.py +++ b/authentik/outposts/api/outpost_service_connections.py @@ -82,7 +82,7 @@ class ServiceConnectionViewSet( "name": subclass._meta.verbose_name, "description": subclass.__doc__, "component": subclass().component, - "model_name": subclass._meta.model_name + "model_name": subclass._meta.model_name, } ) return Response(TypeCreateSerializer(data, many=True).data) diff --git a/authentik/policies/api/policies.py b/authentik/policies/api/policies.py index d300cf1ad..9a089e93a 100644 --- a/authentik/policies/api/policies.py +++ b/authentik/policies/api/policies.py @@ -108,7 +108,7 @@ class PolicyViewSet( "name": subclass._meta.verbose_name, "description": subclass.__doc__, "component": subclass().component, - "model_name": subclass._meta.model_name + "model_name": subclass._meta.model_name, } ) return Response(TypeCreateSerializer(data, many=True).data) diff --git a/authentik/providers/oauth2/views/authorize.py b/authentik/providers/oauth2/views/authorize.py index ee17feb80..538595ec0 100644 --- a/authentik/providers/oauth2/views/authorize.py +++ b/authentik/providers/oauth2/views/authorize.py @@ -6,7 +6,7 @@ from urllib.parse import parse_qs, urlencode, urlsplit, urlunsplit from uuid import uuid4 from django.http import HttpRequest, HttpResponse -from django.http.response import Http404, HttpResponseRedirect +from django.http.response import Http404, HttpResponseBadRequest, HttpResponseRedirect from django.shortcuts import get_object_or_404, redirect from django.utils import timezone from django.utils.translation import gettext as _ @@ -236,6 +236,9 @@ class OAuthFulfillmentStage(StageView): # pylint: disable=unused-argument def get(self, request: HttpRequest, *args, **kwargs) -> HttpResponse: """final Stage of an OAuth2 Flow""" + if PLAN_CONTEXT_PARAMS not in self.executor.plan.context: + LOGGER.warning("Got to fulfillment stage with no pending context") + return HttpResponseBadRequest() self.params: OAuthAuthorizationParams = self.executor.plan.context.pop( PLAN_CONTEXT_PARAMS )