From fe02720f8dc173cb9feb7834b162d51f0e80fd12 Mon Sep 17 00:00:00 2001 From: Jens L Date: Mon, 11 Sep 2023 18:12:04 +0200 Subject: [PATCH] providers/scim: check that a provider exists before starting scim task (#6841) Signed-off-by: Jens Langhammer --- authentik/providers/scim/signals.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/authentik/providers/scim/signals.py b/authentik/providers/scim/signals.py index c9e179ac9..e799044d6 100644 --- a/authentik/providers/scim/signals.py +++ b/authentik/providers/scim/signals.py @@ -23,6 +23,8 @@ def post_save_provider(sender: type[Model], instance, created: bool, **_): @receiver(post_save, sender=Group) def post_save_scim(sender: type[Model], instance: User | Group, created: bool, **_): """Post save handler""" + if not SCIMProvider.objects.filter(backchannel_application__isnull=False).exists(): + return scim_signal_direct.delay(class_to_path(instance.__class__), instance.pk, PatchOp.add.value) @@ -30,6 +32,8 @@ def post_save_scim(sender: type[Model], instance: User | Group, created: bool, * @receiver(pre_delete, sender=Group) def pre_delete_scim(sender: type[Model], instance: User | Group, **_): """Pre-delete handler""" + if not SCIMProvider.objects.filter(backchannel_application__isnull=False).exists(): + return scim_signal_direct.delay(class_to_path(instance.__class__), instance.pk, PatchOp.remove.value) @@ -40,6 +44,8 @@ def m2m_changed_scim( """Sync group membership""" if action not in ["post_add", "post_remove"]: return + if not SCIMProvider.objects.filter(backchannel_application__isnull=False).exists(): + return # reverse: instance is a Group, pk_set is a list of user pks # non-reverse: instance is a User, pk_set is a list of groups if reverse: