From ce0140ef679f55aee357198050a4e6cc2bd20b16 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 11 Feb 2021 19:56:39 +0100 Subject: [PATCH] events: pass Event's user to Notification policy engine when present --- authentik/events/tasks.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/authentik/events/tasks.py b/authentik/events/tasks.py index 68b46f92b..6027ecb97 100644 --- a/authentik/events/tasks.py +++ b/authentik/events/tasks.py @@ -2,6 +2,7 @@ from guardian.shortcuts import get_anonymous_user from structlog import get_logger +from authentik.core.models import User from authentik.events.models import ( Event, Notification, @@ -53,7 +54,8 @@ def event_trigger_handler(event_uuid: str, trigger_name: str): return LOGGER.debug("e(trigger): checking if trigger applies", trigger=trigger) - policy_engine = PolicyEngine(trigger, get_anonymous_user()) + user = User.objects.filter(pk=event.user.get("pk")) or get_anonymous_user() + policy_engine = PolicyEngine(trigger, user) policy_engine.mode = PolicyEngineMode.MODE_OR policy_engine.empty_result = False policy_engine.use_cache = False