From 3e696d6ac81f3c6ae6ad4d1db72e44ee0f9b7aef Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 2 Feb 2021 17:28:06 +0100 Subject: [PATCH] flows: use global logger for stored plans --- authentik/flows/planner.py | 11 +++-------- authentik/flows/views.py | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/authentik/flows/planner.py b/authentik/flows/planner.py index 2f4f390f9..0b9318ccf 100644 --- a/authentik/flows/planner.py +++ b/authentik/flows/planner.py @@ -15,6 +15,7 @@ from authentik.flows.markers import ReevaluateMarker, StageMarker from authentik.flows.models import Flow, FlowStageBinding, Stage from authentik.policies.engine import PolicyEngine +LOGGER = get_logger() PLAN_CONTEXT_PENDING_USER = "pending_user" PLAN_CONTEXT_SSO = "is_sso" PLAN_CONTEXT_REDIRECT = "redirect" @@ -41,8 +42,6 @@ class FlowPlan: context: Dict[str, Any] = field(default_factory=dict) markers: List[StageMarker] = field(default_factory=list) - _logger: BoundLogger = field(default_factory=get_logger) - def append(self, stage: Stage, marker: Optional[StageMarker] = None): """Append `stage` to all stages, optionall with stage marker""" self.stages.append(stage) @@ -56,14 +55,10 @@ class FlowPlan: marker = self.markers[0] if marker.__class__ is not StageMarker: - self._logger.debug( - "f(plan_inst): stage has marker", stage=stage, marker=marker - ) + LOGGER.debug("f(plan_inst): stage has marker", stage=stage, marker=marker) marked_stage = marker.process(self, stage, http_request) if not marked_stage: - self._logger.debug( - "f(plan_inst): marker returned none, next stage", stage=stage - ) + LOGGER.debug("f(plan_inst): marker returned none, next stage", stage=stage) self.stages.remove(stage) self.markers.remove(marker) if not self.has_stages: diff --git a/authentik/flows/views.py b/authentik/flows/views.py index 55e195837..ab98ba850 100644 --- a/authentik/flows/views.py +++ b/authentik/flows/views.py @@ -52,7 +52,7 @@ class FlowExecutorView(View): _logger: BoundLogger def setup(self, request: HttpRequest, flow_slug: str): - super().setup(request) + super().setup(request, flow_slug=flow_slug) self.flow = get_object_or_404(Flow.objects.select_related(), slug=flow_slug) self._logger = get_logger().bind(flow_slug=flow_slug)