From ec254d592722917b22e060e657ebda0b93aad006 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 9 Jul 2021 19:46:39 +0200 Subject: [PATCH] flows: allow variable substitution in flow titles Signed-off-by: Jens Langhammer --- authentik/flows/stage.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/authentik/flows/stage.py b/authentik/flows/stage.py index 93461ce42..f8c4afe8a 100644 --- a/authentik/flows/stage.py +++ b/authentik/flows/stage.py @@ -17,7 +17,7 @@ from authentik.flows.challenge import ( WithUserInfoChallenge, ) from authentik.flows.models import InvalidResponseAction -from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER +from authentik.flows.planner import PLAN_CONTEXT_APPLICATION, PLAN_CONTEXT_PENDING_USER from authentik.flows.views import FlowExecutorView PLAN_CONTEXT_PENDING_USER_IDENTIFIER = "pending_user_identifier" @@ -102,12 +102,18 @@ class ChallengeStageView(StageView): return self.challenge_invalid(challenge) return self.challenge_valid(challenge) + def format_title(self) -> str: + """Allow usage of placeholder in flow title.""" + return self.executor.flow.title % { + "app": self.executor.plan.context.get(PLAN_CONTEXT_APPLICATION, "") + } + def _get_challenge(self, *args, **kwargs) -> Challenge: challenge = self.get_challenge(*args, **kwargs) if "flow_info" not in challenge.initial_data: flow_info = ContextualFlowInfo( data={ - "title": self.executor.flow.title, + "title": self.format_title(), "background": self.executor.flow.background_url, "cancel_url": reverse("authentik_flows:cancel"), }