diff --git a/authentik/events/signals.py b/authentik/events/signals.py index 01b78dd90..a4478239c 100644 --- a/authentik/events/signals.py +++ b/authentik/events/signals.py @@ -1,4 +1,6 @@ """authentik events signal listener""" +from authentik.flows.planner import FlowPlan, PLAN_CONTEXT_SOURCE +from authentik.flows.views import SESSION_KEY_PLAN from threading import Thread from typing import Any, Dict, Optional @@ -46,6 +48,11 @@ class EventNewThread(Thread): def on_user_logged_in(sender, request: HttpRequest, user: User, **_): """Log successful login""" thread = EventNewThread(EventAction.LOGIN, request) + if SESSION_KEY_PLAN in request.session: + flow_plan: FlowPlan = request.session[SESSION_KEY_PLAN] + if PLAN_CONTEXT_SOURCE in flow_plan.context: + # Login request came from an external source, save it in the context + thread.kwargs["using_source"] = flow_plan.context[PLAN_CONTEXT_SOURCE] thread.user = user thread.run() diff --git a/web/src/pages/events/EventInfo.ts b/web/src/pages/events/EventInfo.ts index d7142b09b..f56894965 100644 --- a/web/src/pages/events/EventInfo.ts +++ b/web/src/pages/events/EventInfo.ts @@ -136,6 +136,15 @@ export class EventInfo extends LitElement { // Action types which typically don't record any extra context. // If context is not empty, we fall to the default response. case "login": + if ("using_source" in this.event.context) { + return html`
+
+

${gettext("Using source")}

+ ${this.getModelInfo(this.event.context.using_source as EventContext)} +
+
`; + } + return this.defaultResponse(); case "logout": if (this.event.context === {}) { return html`${gettext("No additional data available.")}`;