diff --git a/authentik/flows/api/flows.py b/authentik/flows/api/flows.py index 9949070ef..f852ef658 100644 --- a/authentik/flows/api/flows.py +++ b/authentik/flows/api/flows.py @@ -297,6 +297,7 @@ class FlowViewSet(UsedByMixin, ModelViewSet): { "link": request._request.build_absolute_uri( reverse_interface( + request, InterfaceType.FLOW, flow_slug=flow.slug, ), diff --git a/authentik/interfaces/views.py b/authentik/interfaces/views.py index ce1f25603..3b6330f7a 100644 --- a/authentik/interfaces/views.py +++ b/authentik/interfaces/views.py @@ -7,12 +7,12 @@ from django.http import Http404, HttpRequest, HttpResponse, QueryDict from django.shortcuts import get_object_or_404, redirect from django.template import Template, TemplateSyntaxError, engines from django.template.response import TemplateResponse -from django.urls import reverse from django.utils.decorators import method_decorator from django.views import View from django.views.decorators.cache import cache_page from django.views.decorators.csrf import ensure_csrf_cookie from rest_framework.request import Request +from structlog.stdlib import get_logger from authentik import get_build_hash from authentik.admin.tasks import LOCAL_VERSION @@ -23,6 +23,8 @@ from authentik.lib.utils.urls import reverse_with_qs from authentik.tenants.api import CurrentTenantSerializer from authentik.tenants.models import Tenant +LOGGER = get_logger() + def template_from_string(template_string: str) -> Template: """Render template from string""" @@ -57,6 +59,7 @@ def reverse_interface( interface = tenant.interface_flow if not interface: + LOGGER.warning("No interface found", type=interface_type, tenant=tenant) raise Http404() kwargs["if_name"] = interface.url_name return reverse_with_qs( diff --git a/authentik/stages/email/stage.py b/authentik/stages/email/stage.py index 752895729..870c226bb 100644 --- a/authentik/stages/email/stage.py +++ b/authentik/stages/email/stage.py @@ -3,7 +3,6 @@ from datetime import timedelta from django.contrib import messages from django.http import HttpRequest, HttpResponse -from django.urls import reverse from django.utils.http import urlencode from django.utils.text import slugify from django.utils.timezone import now diff --git a/authentik/stages/email/tests/test_sending.py b/authentik/stages/email/tests/test_sending.py index b1c2aea15..77ae0c1b8 100644 --- a/authentik/stages/email/tests/test_sending.py +++ b/authentik/stages/email/tests/test_sending.py @@ -7,6 +7,7 @@ from django.core.mail.backends.locmem import EmailBackend from django.urls import reverse from rest_framework.test import APITestCase +from authentik.blueprints.tests import apply_blueprint from authentik.core.tests.utils import create_test_admin_user, create_test_flow from authentik.events.models import Event, EventAction from authentik.flows.markers import StageMarker @@ -29,6 +30,7 @@ class TestEmailStageSending(APITestCase): ) self.binding = FlowStageBinding.objects.create(target=self.flow, stage=self.stage, order=2) + @apply_blueprint("system/interfaces.yaml") def test_pending_user(self): """Test with pending user""" plan = FlowPlan(flow_pk=self.flow.pk.hex, bindings=[self.binding], markers=[StageMarker()]) @@ -54,6 +56,7 @@ class TestEmailStageSending(APITestCase): self.assertEqual(event.context["to_email"], [self.user.email]) self.assertEqual(event.context["from_email"], "system@authentik.local") + @apply_blueprint("system/interfaces.yaml") def test_send_error(self): """Test error during sending (sending will be retried)""" plan = FlowPlan(flow_pk=self.flow.pk.hex, bindings=[self.binding], markers=[StageMarker()]) diff --git a/authentik/stages/email/tests/test_stage.py b/authentik/stages/email/tests/test_stage.py index 32141ba45..92d08ca8f 100644 --- a/authentik/stages/email/tests/test_stage.py +++ b/authentik/stages/email/tests/test_stage.py @@ -7,6 +7,7 @@ from django.core.mail.backends.smtp import EmailBackend as SMTPEmailBackend from django.urls import reverse from django.utils.http import urlencode +from authentik.blueprints.tests import apply_blueprint from authentik.core.tests.utils import create_test_admin_user, create_test_flow from authentik.flows.markers import StageMarker from authentik.flows.models import FlowDesignation, FlowStageBinding, FlowToken @@ -74,6 +75,7 @@ class TestEmailStage(FlowTestCase): response = self.client.get(url) self.assertEqual(response.status_code, 200) + @apply_blueprint("system/interfaces.yaml") @patch( "authentik.stages.email.models.EmailStage.backend_class", PropertyMock(return_value=EmailBackend), @@ -123,6 +125,7 @@ class TestEmailStage(FlowTestCase): with self.settings(EMAIL_HOST=host): self.assertEqual(EmailStage(use_global_settings=True).backend.host, host) + @apply_blueprint("system/interfaces.yaml") def test_token(self): """Test with token""" # Make sure token exists diff --git a/authentik/stages/identification/stage.py b/authentik/stages/identification/stage.py index 8ad9b09cc..93c4e6715 100644 --- a/authentik/stages/identification/stage.py +++ b/authentik/stages/identification/stage.py @@ -29,7 +29,6 @@ from authentik.flows.views.executor import SESSION_KEY_APPLICATION_PRE, SESSION_ from authentik.interfaces.models import InterfaceType from authentik.interfaces.views import reverse_interface from authentik.lib.utils.http import get_client_ip -from authentik.lib.utils.urls import reverse_with_qs from authentik.sources.oauth.types.apple import AppleLoginChallenge from authentik.sources.plex.models import PlexAuthenticationChallenge from authentik.stages.identification.models import IdentificationStage