
* remove pyright Signed-off-by: Jens Langhammer <jens@goauthentik.io> * remove pylint Signed-off-by: Jens Langhammer <jens@goauthentik.io> * replace pylint with ruff Signed-off-by: Jens Langhammer <jens@goauthentik.io> * ruff fix Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> * fix UP038 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix DJ012 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix default arg Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix UP031 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * rename stage type to view Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix DJ008 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix remaining upgrade Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix PLR2004 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix B904 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix PLW2901 Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix remaining issues Signed-off-by: Jens Langhammer <jens@goauthentik.io> * prevent ruff from breaking the code Signed-off-by: Jens Langhammer <jens@goauthentik.io> * stages/prompt: refactor field building Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> * fix tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix lint Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fully remove isort Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io> Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> Co-authored-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
33 lines
1.0 KiB
Python
33 lines
1.0 KiB
Python
"""flow exceptions"""
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from authentik.lib.sentry import SentryIgnoredException
|
|
from authentik.policies.types import PolicyResult
|
|
|
|
|
|
class FlowNonApplicableException(SentryIgnoredException):
|
|
"""Flow does not apply to current user (denied by policy, or otherwise)."""
|
|
|
|
policy_result: PolicyResult | None = None
|
|
|
|
@property
|
|
def messages(self) -> str:
|
|
"""Get messages from policy result, fallback to generic reason"""
|
|
if not self.policy_result or len(self.policy_result.messages) < 1:
|
|
return _("Flow does not apply to current user.")
|
|
return "\n".join(self.policy_result.messages)
|
|
|
|
|
|
class EmptyFlowException(SentryIgnoredException):
|
|
"""Flow has no stages."""
|
|
|
|
|
|
class FlowSkipStageException(SentryIgnoredException):
|
|
"""Exception to skip a stage"""
|
|
|
|
|
|
class StageInvalidException(SentryIgnoredException):
|
|
"""Exception can be thrown in a `Challenge` or `ChallengeResponse` serializer's
|
|
validation to trigger a `executor.stage_invalid()` response"""
|