Revert "refactor"
This reverts commit ecdc8ff3fe25df3062f2adf4295ed506b774da2e.
This commit is contained in:
@ -74,7 +74,7 @@ class ShellChallenge(Challenge):
|
||||
body = CharField()
|
||||
|
||||
|
||||
class WithUserInfoChallengeMixin:
|
||||
class WithUserInfoChallenge(Challenge):
|
||||
"""Challenge base which shows some user info"""
|
||||
|
||||
pending_user = CharField(allow_blank=True)
|
||||
@ -107,7 +107,7 @@ class FlowErrorChallenge(Challenge):
|
||||
self.initial_data["traceback"] = exception_to_string(error)
|
||||
|
||||
|
||||
class AccessDeniedChallenge(WithUserInfoChallengeMixin, Challenge):
|
||||
class AccessDeniedChallenge(WithUserInfoChallenge):
|
||||
"""Challenge when a flow's active stage calls `stage_invalid()`."""
|
||||
|
||||
component = CharField(default="ak-stage-access-denied")
|
||||
@ -115,7 +115,7 @@ class AccessDeniedChallenge(WithUserInfoChallengeMixin, Challenge):
|
||||
error_message = CharField(required=False)
|
||||
|
||||
|
||||
class SessionEndChallenge(WithUserInfoChallengeMixin, Challenge):
|
||||
class SessionEndChallenge(WithUserInfoChallenge):
|
||||
"""Challenge for ending a session"""
|
||||
|
||||
component = CharField(default="ak-stage-session-end")
|
||||
|
@ -23,7 +23,7 @@ from authentik.flows.challenge import (
|
||||
HttpChallengeResponse,
|
||||
RedirectChallenge,
|
||||
SessionEndChallenge,
|
||||
WithUserInfoChallengeMixin,
|
||||
WithUserInfoChallenge,
|
||||
)
|
||||
from authentik.flows.exceptions import StageInvalidException
|
||||
from authentik.flows.models import InvalidResponseAction
|
||||
@ -191,7 +191,7 @@ class ChallengeStageView(StageView):
|
||||
)
|
||||
flow_info.is_valid()
|
||||
challenge.initial_data["flow_info"] = flow_info.data
|
||||
if isinstance(challenge, WithUserInfoChallengeMixin):
|
||||
if isinstance(challenge, WithUserInfoChallenge):
|
||||
# If there's a pending user, update the `username` field
|
||||
# this field is only used by password managers.
|
||||
# If there's no user set, an error is raised later.
|
||||
|
@ -33,6 +33,7 @@ from authentik.flows.challenge import (
|
||||
HttpChallengeResponse,
|
||||
RedirectChallenge,
|
||||
ShellChallenge,
|
||||
WithUserInfoChallenge,
|
||||
)
|
||||
from authentik.flows.exceptions import EmptyFlowException, FlowNonApplicableException
|
||||
from authentik.flows.models import (
|
||||
@ -77,6 +78,8 @@ def challenge_types():
|
||||
subclasses of Challenge, and Challenge itself."""
|
||||
mapping = {}
|
||||
for cls in all_subclasses(Challenge):
|
||||
if cls in [WithUserInfoChallenge]:
|
||||
continue
|
||||
mapping[cls().fields["component"].default] = cls
|
||||
return mapping
|
||||
|
||||
|
@ -8,7 +8,7 @@ from authentik.events.models import Event, EventAction
|
||||
from authentik.flows.challenge import (
|
||||
Challenge,
|
||||
ChallengeResponse,
|
||||
WithUserInfoChallengeMixin,
|
||||
WithUserInfoChallenge,
|
||||
)
|
||||
from authentik.flows.stage import ChallengeStageView
|
||||
from authentik.flows.views.executor import InvalidStageError
|
||||
@ -17,7 +17,7 @@ from authentik.stages.authenticator_duo.models import AuthenticatorDuoStage, Duo
|
||||
SESSION_KEY_DUO_ENROLL = "authentik/stages/authenticator_duo/enroll"
|
||||
|
||||
|
||||
class AuthenticatorDuoChallenge(WithUserInfoChallengeMixin, Challenge):
|
||||
class AuthenticatorDuoChallenge(WithUserInfoChallenge):
|
||||
"""Duo Challenge"""
|
||||
|
||||
activation_barcode = CharField()
|
||||
|
@ -12,7 +12,7 @@ from authentik.events.models import Event, EventAction
|
||||
from authentik.flows.challenge import (
|
||||
Challenge,
|
||||
ChallengeResponse,
|
||||
WithUserInfoChallengeMixin,
|
||||
WithUserInfoChallenge,
|
||||
)
|
||||
from authentik.flows.exceptions import StageInvalidException
|
||||
from authentik.flows.stage import ChallengeStageView
|
||||
@ -33,7 +33,7 @@ PLAN_CONTEXT_EMAIL_SENT = "email_sent"
|
||||
PLAN_CONTEXT_EMAIL_OVERRIDE = "email"
|
||||
|
||||
|
||||
class AuthenticatorEmailChallenge(WithUserInfoChallengeMixin, Challenge):
|
||||
class AuthenticatorEmailChallenge(WithUserInfoChallenge):
|
||||
"""Authenticator Email Setup challenge"""
|
||||
|
||||
# Set to true if no previous prompt stage set the email
|
||||
|
@ -10,7 +10,7 @@ from rest_framework.fields import BooleanField, CharField, IntegerField
|
||||
from authentik.flows.challenge import (
|
||||
Challenge,
|
||||
ChallengeResponse,
|
||||
WithUserInfoChallengeMixin,
|
||||
WithUserInfoChallenge,
|
||||
)
|
||||
from authentik.flows.stage import ChallengeStageView
|
||||
from authentik.stages.authenticator_sms.models import (
|
||||
@ -24,7 +24,7 @@ SESSION_KEY_SMS_DEVICE = "authentik/stages/authenticator_sms/sms_device"
|
||||
PLAN_CONTEXT_PHONE = "phone"
|
||||
|
||||
|
||||
class AuthenticatorSMSChallenge(WithUserInfoChallengeMixin, Challenge):
|
||||
class AuthenticatorSMSChallenge(WithUserInfoChallenge):
|
||||
"""SMS Setup challenge"""
|
||||
|
||||
# Set to true if no previous prompt stage set the phone number
|
||||
|
@ -3,7 +3,7 @@
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from rest_framework.fields import CharField, ListField
|
||||
|
||||
from authentik.flows.challenge import Challenge, ChallengeResponse, WithUserInfoChallengeMixin
|
||||
from authentik.flows.challenge import ChallengeResponse, WithUserInfoChallenge
|
||||
from authentik.flows.stage import ChallengeStageView
|
||||
from authentik.lib.generators import generate_id
|
||||
from authentik.stages.authenticator_static.models import (
|
||||
@ -16,7 +16,7 @@ SESSION_STATIC_DEVICE = "static_device"
|
||||
SESSION_STATIC_TOKENS = "static_device_tokens"
|
||||
|
||||
|
||||
class AuthenticatorStaticChallenge(WithUserInfoChallengeMixin, Challenge):
|
||||
class AuthenticatorStaticChallenge(WithUserInfoChallenge):
|
||||
"""Static authenticator challenge"""
|
||||
|
||||
codes = ListField(child=CharField())
|
||||
|
@ -11,7 +11,7 @@ from rest_framework.serializers import ValidationError
|
||||
from authentik.flows.challenge import (
|
||||
Challenge,
|
||||
ChallengeResponse,
|
||||
WithUserInfoChallengeMixin,
|
||||
WithUserInfoChallenge,
|
||||
)
|
||||
from authentik.flows.stage import ChallengeStageView
|
||||
from authentik.stages.authenticator_totp.models import AuthenticatorTOTPStage, TOTPDevice
|
||||
@ -20,7 +20,7 @@ from authentik.stages.authenticator_totp.settings import OTP_TOTP_ISSUER
|
||||
SESSION_TOTP_DEVICE = "totp_device"
|
||||
|
||||
|
||||
class AuthenticatorTOTPChallenge(WithUserInfoChallengeMixin, Challenge):
|
||||
class AuthenticatorTOTPChallenge(WithUserInfoChallenge):
|
||||
"""TOTP Setup challenge"""
|
||||
|
||||
config_url = CharField()
|
||||
|
@ -15,7 +15,7 @@ from authentik.core.api.utils import JSONDictField, PassiveSerializer
|
||||
from authentik.core.models import User
|
||||
from authentik.events.middleware import audit_ignore
|
||||
from authentik.events.models import Event, EventAction
|
||||
from authentik.flows.challenge import Challenge, ChallengeResponse, WithUserInfoChallengeMixin
|
||||
from authentik.flows.challenge import ChallengeResponse, WithUserInfoChallenge
|
||||
from authentik.flows.exceptions import FlowSkipStageException, StageInvalidException
|
||||
from authentik.flows.models import FlowDesignation, NotConfiguredAction, Stage
|
||||
from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER
|
||||
@ -55,7 +55,7 @@ class SelectableStageSerializer(PassiveSerializer):
|
||||
meta_model_name = CharField()
|
||||
|
||||
|
||||
class AuthenticatorValidationChallenge(WithUserInfoChallengeMixin, Challenge):
|
||||
class AuthenticatorValidationChallenge(WithUserInfoChallenge):
|
||||
"""Authenticator challenge"""
|
||||
|
||||
device_challenges = ListField(child=DeviceChallenge())
|
||||
|
@ -30,7 +30,7 @@ from authentik.core.models import User
|
||||
from authentik.flows.challenge import (
|
||||
Challenge,
|
||||
ChallengeResponse,
|
||||
WithUserInfoChallengeMixin,
|
||||
WithUserInfoChallenge,
|
||||
)
|
||||
from authentik.flows.stage import ChallengeStageView
|
||||
from authentik.stages.authenticator_webauthn.models import (
|
||||
@ -44,7 +44,7 @@ from authentik.stages.authenticator_webauthn.utils import get_origin, get_rp_id
|
||||
SESSION_KEY_WEBAUTHN_CHALLENGE = "authentik/stages/authenticator_webauthn/challenge"
|
||||
|
||||
|
||||
class AuthenticatorWebAuthnChallenge(WithUserInfoChallengeMixin, Challenge):
|
||||
class AuthenticatorWebAuthnChallenge(WithUserInfoChallenge):
|
||||
"""WebAuthn Challenge"""
|
||||
|
||||
registration = JSONDictField()
|
||||
|
@ -10,7 +10,7 @@ from structlog.stdlib import get_logger
|
||||
from authentik.flows.challenge import (
|
||||
Challenge,
|
||||
ChallengeResponse,
|
||||
WithUserInfoChallengeMixin,
|
||||
WithUserInfoChallenge,
|
||||
)
|
||||
from authentik.flows.stage import ChallengeStageView
|
||||
from authentik.lib.utils.http import get_http_session
|
||||
@ -21,7 +21,7 @@ LOGGER = get_logger()
|
||||
PLAN_CONTEXT_CAPTCHA = "captcha"
|
||||
|
||||
|
||||
class CaptchaChallenge(WithUserInfoChallengeMixin, Challenge):
|
||||
class CaptchaChallenge(WithUserInfoChallenge):
|
||||
"""Site public key"""
|
||||
|
||||
component = CharField(default="ak-stage-captcha")
|
||||
|
@ -10,7 +10,7 @@ from authentik.core.api.utils import PassiveSerializer
|
||||
from authentik.flows.challenge import (
|
||||
Challenge,
|
||||
ChallengeResponse,
|
||||
WithUserInfoChallengeMixin,
|
||||
WithUserInfoChallenge,
|
||||
)
|
||||
from authentik.flows.planner import PLAN_CONTEXT_APPLICATION, PLAN_CONTEXT_PENDING_USER
|
||||
from authentik.flows.stage import ChallengeStageView
|
||||
@ -31,7 +31,7 @@ class ConsentPermissionSerializer(PassiveSerializer):
|
||||
id = CharField()
|
||||
|
||||
|
||||
class ConsentChallenge(WithUserInfoChallengeMixin, Challenge):
|
||||
class ConsentChallenge(WithUserInfoChallenge):
|
||||
"""Challenge info for consent screens"""
|
||||
|
||||
header_text = CharField(required=False)
|
||||
|
@ -18,7 +18,7 @@ from authentik.core.signals import login_failed
|
||||
from authentik.flows.challenge import (
|
||||
Challenge,
|
||||
ChallengeResponse,
|
||||
WithUserInfoChallengeMixin,
|
||||
WithUserInfoChallenge,
|
||||
)
|
||||
from authentik.flows.exceptions import StageInvalidException
|
||||
from authentik.flows.models import Flow, Stage
|
||||
@ -69,7 +69,7 @@ def authenticate(
|
||||
)
|
||||
|
||||
|
||||
class PasswordChallenge(WithUserInfoChallengeMixin, Challenge):
|
||||
class PasswordChallenge(WithUserInfoChallenge):
|
||||
"""Password challenge UI fields"""
|
||||
|
||||
recovery_url = CharField(required=False)
|
||||
|
@ -10,7 +10,7 @@ from rest_framework.fields import BooleanField, CharField
|
||||
|
||||
from authentik.core.models import Session, User
|
||||
from authentik.events.middleware import audit_ignore
|
||||
from authentik.flows.challenge import Challenge, ChallengeResponse, WithUserInfoChallengeMixin
|
||||
from authentik.flows.challenge import ChallengeResponse, WithUserInfoChallenge
|
||||
from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER, PLAN_CONTEXT_SOURCE
|
||||
from authentik.flows.stage import ChallengeStageView
|
||||
from authentik.lib.utils.time import timedelta_from_string
|
||||
@ -24,7 +24,7 @@ from authentik.stages.user_login.middleware import (
|
||||
from authentik.stages.user_login.models import UserLoginStage
|
||||
|
||||
|
||||
class UserLoginChallenge(WithUserInfoChallengeMixin, Challenge):
|
||||
class UserLoginChallenge(WithUserInfoChallenge):
|
||||
"""Empty challenge"""
|
||||
|
||||
component = CharField(default="ak-stage-user-login")
|
||||
|
Reference in New Issue
Block a user