sources/*: Set PLAN_CONTEXT_SOURCE when logging in with a source
This commit is contained in:
parent
47ddf0d7f2
commit
61d1407804
|
@ -21,6 +21,7 @@ PLAN_CONTEXT_PENDING_USER = "pending_user"
|
||||||
PLAN_CONTEXT_SSO = "is_sso"
|
PLAN_CONTEXT_SSO = "is_sso"
|
||||||
PLAN_CONTEXT_REDIRECT = "redirect"
|
PLAN_CONTEXT_REDIRECT = "redirect"
|
||||||
PLAN_CONTEXT_APPLICATION = "application"
|
PLAN_CONTEXT_APPLICATION = "application"
|
||||||
|
PLAN_CONTEXT_SOURCE = "source"
|
||||||
|
|
||||||
|
|
||||||
def cache_key(flow: Flow, user: Optional[User] = None) -> str:
|
def cache_key(flow: Flow, user: Optional[User] = None) -> str:
|
||||||
|
|
|
@ -15,7 +15,7 @@ from authentik.events.models import Event, EventAction
|
||||||
from authentik.flows.models import Flow, in_memory_stage
|
from authentik.flows.models import Flow, in_memory_stage
|
||||||
from authentik.flows.planner import (
|
from authentik.flows.planner import (
|
||||||
PLAN_CONTEXT_PENDING_USER,
|
PLAN_CONTEXT_PENDING_USER,
|
||||||
PLAN_CONTEXT_REDIRECT,
|
PLAN_CONTEXT_REDIRECT, PLAN_CONTEXT_SOURCE,
|
||||||
PLAN_CONTEXT_SSO,
|
PLAN_CONTEXT_SSO,
|
||||||
FlowPlanner,
|
FlowPlanner,
|
||||||
)
|
)
|
||||||
|
@ -146,6 +146,7 @@ class OAuthCallback(OAuthClientMixin, View):
|
||||||
# Since we authenticate the user by their token, they have no backend set
|
# Since we authenticate the user by their token, they have no backend set
|
||||||
PLAN_CONTEXT_AUTHENTICATION_BACKEND: "django.contrib.auth.backends.ModelBackend",
|
PLAN_CONTEXT_AUTHENTICATION_BACKEND: "django.contrib.auth.backends.ModelBackend",
|
||||||
PLAN_CONTEXT_SSO: True,
|
PLAN_CONTEXT_SSO: True,
|
||||||
|
PLAN_CONTEXT_SOURCE: self.source,
|
||||||
PLAN_CONTEXT_REDIRECT: final_redirect,
|
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
|
# Since we authenticate the user by their token, they have no backend set
|
||||||
PLAN_CONTEXT_AUTHENTICATION_BACKEND: "django.contrib.auth.backends.ModelBackend",
|
PLAN_CONTEXT_AUTHENTICATION_BACKEND: "django.contrib.auth.backends.ModelBackend",
|
||||||
PLAN_CONTEXT_SSO: True,
|
PLAN_CONTEXT_SSO: True,
|
||||||
|
PLAN_CONTEXT_SOURCE: self.source,
|
||||||
PLAN_CONTEXT_PROMPT: delete_none_keys(
|
PLAN_CONTEXT_PROMPT: delete_none_keys(
|
||||||
self.get_user_enroll_context(source, access, info)
|
self.get_user_enroll_context(source, access, info)
|
||||||
),
|
),
|
||||||
|
|
|
@ -13,7 +13,7 @@ from authentik.core.models import User
|
||||||
from authentik.flows.models import Flow
|
from authentik.flows.models import Flow
|
||||||
from authentik.flows.planner import (
|
from authentik.flows.planner import (
|
||||||
PLAN_CONTEXT_PENDING_USER,
|
PLAN_CONTEXT_PENDING_USER,
|
||||||
PLAN_CONTEXT_REDIRECT,
|
PLAN_CONTEXT_REDIRECT, PLAN_CONTEXT_SOURCE,
|
||||||
PLAN_CONTEXT_SSO,
|
PLAN_CONTEXT_SSO,
|
||||||
FlowPlanner,
|
FlowPlanner,
|
||||||
)
|
)
|
||||||
|
@ -217,6 +217,7 @@ class ResponseProcessor:
|
||||||
self, request: HttpRequest, flow: Flow, **kwargs
|
self, request: HttpRequest, flow: Flow, **kwargs
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
kwargs[PLAN_CONTEXT_SSO] = True
|
kwargs[PLAN_CONTEXT_SSO] = True
|
||||||
|
kwargs[PLAN_CONTEXT_SOURCE] = self._source
|
||||||
request.session[SESSION_KEY_PLAN] = FlowPlanner(flow).plan(request, kwargs)
|
request.session[SESSION_KEY_PLAN] = FlowPlanner(flow).plan(request, kwargs)
|
||||||
return redirect_with_qs(
|
return redirect_with_qs(
|
||||||
"authentik_flows:flow-executor-shell",
|
"authentik_flows:flow-executor-shell",
|
||||||
|
|
Reference in New Issue