From 6f3eb4c068b74f345ee55faa2f3aed3095b32a4d Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 25 May 2021 12:53:48 +0200 Subject: [PATCH] flows: allow blank on WithUserInfo Signed-off-by: Jens Langhammer --- authentik/flows/challenge.py | 2 +- authentik/sources/saml/views.py | 7 ++----- authentik/stages/consent/stage.py | 22 +++++++++------------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/authentik/flows/challenge.py b/authentik/flows/challenge.py index 233325eeb..62887c2b7 100644 --- a/authentik/flows/challenge.py +++ b/authentik/flows/challenge.py @@ -61,7 +61,7 @@ class ShellChallenge(Challenge): class WithUserInfoChallenge(Challenge): """Challenge base which shows some user info""" - pending_user = CharField() + pending_user = CharField(allow_blank=True) pending_user_avatar = CharField() diff --git a/authentik/sources/saml/views.py b/authentik/sources/saml/views.py index afd16b38a..2685e3df4 100644 --- a/authentik/sources/saml/views.py +++ b/authentik/sources/saml/views.py @@ -8,7 +8,6 @@ from django.http.response import HttpResponseBadRequest from django.shortcuts import get_object_or_404, redirect from django.utils.decorators import method_decorator from django.utils.http import urlencode -from django.utils.translation import gettext_lazy as _ from django.views import View from django.views.decorators.csrf import csrf_exempt from structlog.stdlib import get_logger @@ -134,10 +133,8 @@ class InitiateView(View): return bad_request_message(request, str(exc)) injected_stages = [] plan_kwargs = { - PLAN_CONTEXT_TITLE: _("Redirecting to %(app)s..." % {"app": source.name}), - PLAN_CONTEXT_CONSENT_TITLE: _( - "Redirecting to %(app)s..." % {"app": source.name} - ), + PLAN_CONTEXT_TITLE: f"Redirecting to {source.name}...", + PLAN_CONTEXT_CONSENT_TITLE: f"Redirecting to {source.name}...", PLAN_CONTEXT_ATTRS: { "SAMLRequest": saml_request, "RelayState": relay_state, diff --git a/authentik/stages/consent/stage.py b/authentik/stages/consent/stage.py index 9ba75a2a0..8227ebf91 100644 --- a/authentik/stages/consent/stage.py +++ b/authentik/stages/consent/stage.py @@ -40,23 +40,19 @@ class ConsentStageView(ChallengeStageView): response_class = ConsentChallengeResponse def get_challenge(self) -> Challenge: - challenge = ConsentChallenge( - data={ - "type": ChallengeTypes.NATIVE.value, - } - ) + data = { + "type": ChallengeTypes.NATIVE.value, + "permissions": self.executor.plan.context.get( + PLAN_CONTEXT_CONSENT_PERMISSIONS, [] + ), + } if PLAN_CONTEXT_CONSENT_TITLE in self.executor.plan.context: - challenge.initial_data["title"] = self.executor.plan.context[ - PLAN_CONTEXT_CONSENT_TITLE - ] + data["title"] = self.executor.plan.context[PLAN_CONTEXT_CONSENT_TITLE] if PLAN_CONTEXT_CONSENT_HEADER in self.executor.plan.context: - challenge.initial_data["header_text"] = self.executor.plan.context[ + data["header_text"] = self.executor.plan.context[ PLAN_CONTEXT_CONSENT_HEADER ] - if PLAN_CONTEXT_CONSENT_PERMISSIONS in self.executor.plan.context: - challenge.initial_data["permissions"] = self.executor.plan.context[ - PLAN_CONTEXT_CONSENT_PERMISSIONS - ] + challenge = ConsentChallenge(data=data) return challenge def get(self, request: HttpRequest, *args, **kwargs) -> HttpResponse: