diff --git a/authentik/flows/planner.py b/authentik/flows/planner.py index 7ed49a69b3..8105051e6c 100644 --- a/authentik/flows/planner.py +++ b/authentik/flows/planner.py @@ -21,6 +21,7 @@ PLAN_CONTEXT_PENDING_USER = "pending_user" PLAN_CONTEXT_SSO = "is_sso" PLAN_CONTEXT_REDIRECT = "redirect" PLAN_CONTEXT_APPLICATION = "application" +PLAN_CONTEXT_SOURCE = "source" def cache_key(flow: Flow, user: Optional[User] = None) -> str: diff --git a/authentik/sources/oauth/views/callback.py b/authentik/sources/oauth/views/callback.py index fc91e730ab..bd0d249e4c 100644 --- a/authentik/sources/oauth/views/callback.py +++ b/authentik/sources/oauth/views/callback.py @@ -15,7 +15,7 @@ from authentik.events.models import Event, EventAction from authentik.flows.models import Flow, in_memory_stage from authentik.flows.planner import ( PLAN_CONTEXT_PENDING_USER, - PLAN_CONTEXT_REDIRECT, + PLAN_CONTEXT_REDIRECT, PLAN_CONTEXT_SOURCE, PLAN_CONTEXT_SSO, FlowPlanner, ) @@ -146,6 +146,7 @@ class OAuthCallback(OAuthClientMixin, View): # Since we authenticate the user by their token, they have no backend set PLAN_CONTEXT_AUTHENTICATION_BACKEND: "django.contrib.auth.backends.ModelBackend", PLAN_CONTEXT_SSO: True, + PLAN_CONTEXT_SOURCE: self.source, PLAN_CONTEXT_REDIRECT: final_redirect, } ) @@ -224,6 +225,7 @@ class OAuthCallback(OAuthClientMixin, View): # Since we authenticate the user by their token, they have no backend set PLAN_CONTEXT_AUTHENTICATION_BACKEND: "django.contrib.auth.backends.ModelBackend", PLAN_CONTEXT_SSO: True, + PLAN_CONTEXT_SOURCE: self.source, PLAN_CONTEXT_PROMPT: delete_none_keys( self.get_user_enroll_context(source, access, info) ), diff --git a/authentik/sources/saml/processors/response.py b/authentik/sources/saml/processors/response.py index 6553658494..bfa3337f05 100644 --- a/authentik/sources/saml/processors/response.py +++ b/authentik/sources/saml/processors/response.py @@ -13,7 +13,7 @@ from authentik.core.models import User from authentik.flows.models import Flow from authentik.flows.planner import ( PLAN_CONTEXT_PENDING_USER, - PLAN_CONTEXT_REDIRECT, + PLAN_CONTEXT_REDIRECT, PLAN_CONTEXT_SOURCE, PLAN_CONTEXT_SSO, FlowPlanner, ) @@ -217,6 +217,7 @@ class ResponseProcessor: self, request: HttpRequest, flow: Flow, **kwargs ) -> HttpResponse: kwargs[PLAN_CONTEXT_SSO] = True + kwargs[PLAN_CONTEXT_SOURCE] = self._source request.session[SESSION_KEY_PLAN] = FlowPlanner(flow).plan(request, kwargs) return redirect_with_qs( "authentik_flows:flow-executor-shell",