authentik.flows.exceptions

flow exceptions

 1"""flow exceptions"""
 2
 3from django.utils.translation import gettext_lazy as _
 4
 5from authentik.lib.tracing.exceptions import TracingIgnoredException
 6from authentik.policies.types import PolicyResult
 7
 8
 9class FlowNonApplicableException(TracingIgnoredException):
10    """Flow does not apply to current user (denied by policy, or otherwise)."""
11
12    policy_result: PolicyResult | None = None
13
14    def __init__(self, policy_result: PolicyResult | None = None, *args):
15        super().__init__(*args)
16        self.policy_result = policy_result
17
18    @property
19    def messages(self) -> str:
20        """Get messages from policy result, fallback to generic reason"""
21        if not self.policy_result or len(self.policy_result.messages) < 1:
22            return _("Flow does not apply to current user.")
23        return "\n".join(self.policy_result.messages)
24
25
26class EmptyFlowException(TracingIgnoredException):
27    """Flow has no stages."""
28
29
30class FlowSkipStageException(TracingIgnoredException):
31    """Exception to skip a stage"""
32
33
34class StageInvalidException(TracingIgnoredException):
35    """Exception can be thrown in a `Challenge` or `ChallengeResponse` serializer's
36    validation to trigger a `executor.stage_invalid()` response"""
class FlowNonApplicableException(authentik.lib.tracing.exceptions.TracingIgnoredException):
10class FlowNonApplicableException(TracingIgnoredException):
11    """Flow does not apply to current user (denied by policy, or otherwise)."""
12
13    policy_result: PolicyResult | None = None
14
15    def __init__(self, policy_result: PolicyResult | None = None, *args):
16        super().__init__(*args)
17        self.policy_result = policy_result
18
19    @property
20    def messages(self) -> str:
21        """Get messages from policy result, fallback to generic reason"""
22        if not self.policy_result or len(self.policy_result.messages) < 1:
23            return _("Flow does not apply to current user.")
24        return "\n".join(self.policy_result.messages)

Flow does not apply to current user (denied by policy, or otherwise).

FlowNonApplicableException( policy_result: authentik.policies.types.PolicyResult | None = None, *args)
15    def __init__(self, policy_result: PolicyResult | None = None, *args):
16        super().__init__(*args)
17        self.policy_result = policy_result
policy_result: authentik.policies.types.PolicyResult | None = None
messages: str
19    @property
20    def messages(self) -> str:
21        """Get messages from policy result, fallback to generic reason"""
22        if not self.policy_result or len(self.policy_result.messages) < 1:
23            return _("Flow does not apply to current user.")
24        return "\n".join(self.policy_result.messages)

Get messages from policy result, fallback to generic reason

class EmptyFlowException(authentik.lib.tracing.exceptions.TracingIgnoredException):
27class EmptyFlowException(TracingIgnoredException):
28    """Flow has no stages."""

Flow has no stages.

class FlowSkipStageException(authentik.lib.tracing.exceptions.TracingIgnoredException):
31class FlowSkipStageException(TracingIgnoredException):
32    """Exception to skip a stage"""

Exception to skip a stage

class StageInvalidException(authentik.lib.tracing.exceptions.TracingIgnoredException):
35class StageInvalidException(TracingIgnoredException):
36    """Exception can be thrown in a `Challenge` or `ChallengeResponse` serializer's
37    validation to trigger a `executor.stage_invalid()` response"""

Exception can be thrown in a Challenge or ChallengeResponse serializer's validation to trigger a executor.stage_invalid() response