diff --git a/authentik/flows/tests/test_views.py b/authentik/flows/tests/test_views.py index f06ba18b5..40940196c 100644 --- a/authentik/flows/tests/test_views.py +++ b/authentik/flows/tests/test_views.py @@ -289,7 +289,11 @@ class TestFlowExecutor(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) def test_reevaluate_keep(self): @@ -366,7 +370,11 @@ class TestFlowExecutor(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) def test_reevaluate_remove_consecutive(self): @@ -458,7 +466,11 @@ class TestFlowExecutor(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) def test_stageview_user_identifier(self): diff --git a/authentik/providers/oauth2/tests/test_authorize.py b/authentik/providers/oauth2/tests/test_authorize.py index 2c0d03955..b78d674d2 100644 --- a/authentik/providers/oauth2/tests/test_authorize.py +++ b/authentik/providers/oauth2/tests/test_authorize.py @@ -194,6 +194,7 @@ class TestAuthorize(OAuthTestCase): self.assertJSONEqual( force_str(response.content), { + "component": "xak-flow-redirect", "type": ChallengeTypes.REDIRECT.value, "to": f"foo://localhost?code={code.code}&state={state}", }, @@ -232,6 +233,7 @@ class TestAuthorize(OAuthTestCase): self.assertJSONEqual( force_str(response.content), { + "component": "xak-flow-redirect", "type": ChallengeTypes.REDIRECT.value, "to": ( f"http://localhost#access_token={token.access_token}" diff --git a/authentik/stages/captcha/tests.py b/authentik/stages/captcha/tests.py index b6b5f5bae..3579438e5 100644 --- a/authentik/stages/captcha/tests.py +++ b/authentik/stages/captcha/tests.py @@ -4,6 +4,7 @@ from django.urls import reverse from django.utils.encoding import force_str from authentik.core.models import User +from authentik.flows.challenge import ChallengeTypes from authentik.flows.markers import StageMarker from authentik.flows.models import Flow, FlowDesignation, FlowStageBinding from authentik.flows.planner import FlowPlan @@ -54,5 +55,9 @@ class TestCaptchaStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) diff --git a/authentik/stages/consent/tests.py b/authentik/stages/consent/tests.py index bdd8bc0a9..d395af6a0 100644 --- a/authentik/stages/consent/tests.py +++ b/authentik/stages/consent/tests.py @@ -7,6 +7,7 @@ from django.utils.encoding import force_str from authentik.core.models import Application, User from authentik.core.tasks import clean_expired_models +from authentik.flows.challenge import ChallengeTypes from authentik.flows.markers import StageMarker from authentik.flows.models import Flow, FlowDesignation, FlowStageBinding from authentik.flows.planner import PLAN_CONTEXT_APPLICATION, FlowPlan @@ -51,7 +52,11 @@ class TestConsentStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) self.assertFalse(UserConsent.objects.filter(user=self.user).exists()) @@ -82,7 +87,11 @@ class TestConsentStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) self.assertTrue( UserConsent.objects.filter( @@ -119,7 +128,11 @@ class TestConsentStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) self.assertTrue( UserConsent.objects.filter( diff --git a/authentik/stages/dummy/tests.py b/authentik/stages/dummy/tests.py index 1bfdef559..0b173feff 100644 --- a/authentik/stages/dummy/tests.py +++ b/authentik/stages/dummy/tests.py @@ -4,6 +4,7 @@ from django.urls import reverse from django.utils.encoding import force_str from authentik.core.models import User +from authentik.flows.challenge import ChallengeTypes from authentik.flows.models import Flow, FlowDesignation, FlowStageBinding from authentik.stages.dummy.models import DummyStage @@ -45,5 +46,9 @@ class TestDummyStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) diff --git a/authentik/stages/email/tests/test_stage.py b/authentik/stages/email/tests/test_stage.py index 432ee5f24..ae499b05b 100644 --- a/authentik/stages/email/tests/test_stage.py +++ b/authentik/stages/email/tests/test_stage.py @@ -8,6 +8,7 @@ from django.utils.encoding import force_str from django.utils.http import urlencode from authentik.core.models import Token, User +from authentik.flows.challenge import ChallengeTypes from authentik.flows.markers import StageMarker from authentik.flows.models import Flow, FlowDesignation, FlowStageBinding from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER, FlowPlan @@ -133,7 +134,11 @@ class TestEmailStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) session = self.client.session diff --git a/authentik/stages/identification/stage.py b/authentik/stages/identification/stage.py index 69e2053f9..163345e64 100644 --- a/authentik/stages/identification/stage.py +++ b/authentik/stages/identification/stage.py @@ -86,6 +86,7 @@ class IdentificationStageView(ChallengeStageView): data={ "type": ChallengeTypes.NATIVE.value, "primary_action": _("Log in"), + "component": "ak-stage-identification", "user_fields": current_stage.user_fields, } ) diff --git a/authentik/stages/identification/tests.py b/authentik/stages/identification/tests.py index 64c051ddc..9a09ce5d9 100644 --- a/authentik/stages/identification/tests.py +++ b/authentik/stages/identification/tests.py @@ -53,7 +53,11 @@ class TestIdentificationStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) def test_invalid_with_username(self): @@ -118,8 +122,9 @@ class TestIdentificationStage(TestCase): "icon_url": "/static/authentik/sources/.svg", "name": "test", "challenge": { + "component": "xak-flow-redirect", "to": "/source/oauth/login/test/", - "type": "redirect", + "type": ChallengeTypes.REDIRECT.value, }, } ], @@ -162,8 +167,9 @@ class TestIdentificationStage(TestCase): "sources": [ { "challenge": { + "component": "xak-flow-redirect", "to": "/source/oauth/login/test/", - "type": "redirect", + "type": ChallengeTypes.REDIRECT.value, }, "icon_url": "/static/authentik/sources/.svg", "name": "test", diff --git a/authentik/stages/invitation/tests.py b/authentik/stages/invitation/tests.py index 7e1b166c4..8d3cc3afe 100644 --- a/authentik/stages/invitation/tests.py +++ b/authentik/stages/invitation/tests.py @@ -89,7 +89,11 @@ class TestUserLoginStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) self.stage.continue_flow_without_invitation = False @@ -123,7 +127,11 @@ class TestUserLoginStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) def test_with_invitation_prompt_data(self): @@ -154,7 +162,11 @@ class TestUserLoginStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) self.assertFalse(Invitation.objects.filter(pk=invite.pk)) diff --git a/authentik/stages/password/tests.py b/authentik/stages/password/tests.py index 273c9834b..21a9a8f99 100644 --- a/authentik/stages/password/tests.py +++ b/authentik/stages/password/tests.py @@ -118,7 +118,11 @@ class TestPasswordStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) def test_invalid_password(self): diff --git a/authentik/stages/prompt/stage.py b/authentik/stages/prompt/stage.py index a1d4c3038..c231ff696 100644 --- a/authentik/stages/prompt/stage.py +++ b/authentik/stages/prompt/stage.py @@ -51,9 +51,11 @@ class PromptResponseChallenge(ChallengeResponse): component = CharField(default="ak-stage-prompt") def __init__(self, *args, **kwargs): + stage: PromptStage = kwargs.pop("stage", None) + plan: FlowPlan = kwargs.pop("plan", None) super().__init__(*args, **kwargs) - self.stage: PromptStage = kwargs.pop("stage", None) - self.plan: FlowPlan = kwargs.pop("plan", None) + self.stage = stage + self.plan = plan if not self.stage: return # list() is called so we only load the fields once diff --git a/authentik/stages/prompt/tests.py b/authentik/stages/prompt/tests.py index 941a99142..11d09ce02 100644 --- a/authentik/stages/prompt/tests.py +++ b/authentik/stages/prompt/tests.py @@ -6,6 +6,7 @@ from django.urls import reverse from django.utils.encoding import force_str from authentik.core.models import User +from authentik.flows.challenge import ChallengeTypes from authentik.flows.markers import StageMarker from authentik.flows.models import Flow, FlowDesignation, FlowStageBinding from authentik.flows.planner import FlowPlan @@ -167,7 +168,11 @@ class TestPromptStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) # Check that valid data has been saved diff --git a/authentik/stages/user_delete/tests.py b/authentik/stages/user_delete/tests.py index 48d0a86b7..b3d1bcf14 100644 --- a/authentik/stages/user_delete/tests.py +++ b/authentik/stages/user_delete/tests.py @@ -75,7 +75,11 @@ class TestUserDeleteStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) self.assertFalse(User.objects.filter(username=self.username).exists()) diff --git a/authentik/stages/user_login/tests.py b/authentik/stages/user_login/tests.py index 33c921e17..003f42c40 100644 --- a/authentik/stages/user_login/tests.py +++ b/authentik/stages/user_login/tests.py @@ -49,7 +49,11 @@ class TestUserLoginStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) def test_expiry(self): @@ -70,7 +74,11 @@ class TestUserLoginStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) self.assertNotEqual(list(self.client.session.keys()), []) sleep(3) diff --git a/authentik/stages/user_logout/tests.py b/authentik/stages/user_logout/tests.py index 4eb464f6a..04c2d5111 100644 --- a/authentik/stages/user_logout/tests.py +++ b/authentik/stages/user_logout/tests.py @@ -4,6 +4,7 @@ from django.urls import reverse from django.utils.encoding import force_str from authentik.core.models import User +from authentik.flows.challenge import ChallengeTypes from authentik.flows.markers import StageMarker from authentik.flows.models import Flow, FlowDesignation, FlowStageBinding from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER, FlowPlan @@ -48,5 +49,9 @@ class TestUserLogoutStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) diff --git a/authentik/stages/user_write/tests.py b/authentik/stages/user_write/tests.py index d9f3de1f4..55c217b56 100644 --- a/authentik/stages/user_write/tests.py +++ b/authentik/stages/user_write/tests.py @@ -60,7 +60,11 @@ class TestUserWriteStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) user_qs = User.objects.filter( username=plan.context[PLAN_CONTEXT_PROMPT]["username"] @@ -97,7 +101,11 @@ class TestUserWriteStage(TestCase): self.assertEqual(response.status_code, 200) self.assertJSONEqual( force_str(response.content), - {"to": reverse("authentik_core:root-redirect"), "type": "redirect"}, + { + "component": "xak-flow-redirect", + "to": reverse("authentik_core:root-redirect"), + "type": ChallengeTypes.REDIRECT.value, + }, ) user_qs = User.objects.filter( username=plan.context[PLAN_CONTEXT_PROMPT]["username"]