diff --git a/authentik/outposts/signals.py b/authentik/outposts/signals.py index aad761cdc..b4f1a6151 100644 --- a/authentik/outposts/signals.py +++ b/authentik/outposts/signals.py @@ -4,11 +4,19 @@ from django.db.models.signals import post_save, pre_delete from django.dispatch import receiver from structlog.stdlib import get_logger +from authentik.core.models import Provider +from authentik.crypto.models import CertificateKeyPair from authentik.lib.utils.reflection import class_to_path -from authentik.outposts.models import Outpost +from authentik.outposts.models import Outpost, OutpostServiceConnection from authentik.outposts.tasks import outpost_post_save, outpost_pre_delete LOGGER = get_logger() +UPDATE_TRIGGERING_MODELS = ( + Outpost, + OutpostServiceConnection, + Provider, + CertificateKeyPair, +) @receiver(post_save) @@ -22,6 +30,8 @@ def post_save_update(sender, instance: Model, **_): return if instance.__module__ == "__fake__": return + if sender not in UPDATE_TRIGGERING_MODELS: + return outpost_post_save.delay(class_to_path(instance.__class__), instance.pk) diff --git a/authentik/outposts/tasks.py b/authentik/outposts/tasks.py index 8ecb8ca3c..da05a41cf 100644 --- a/authentik/outposts/tasks.py +++ b/authentik/outposts/tasks.py @@ -124,14 +124,12 @@ def outpost_post_save(model_class: str, model_pk: Any): _ = instance.token LOGGER.debug("Trigger reconcile for outpost") outpost_controller.delay(instance.pk) - return if isinstance(instance, (OutpostModel, Outpost)): LOGGER.debug( "triggering outpost update from outpostmodel/outpost", instance=instance ) outpost_send_update(instance) - return if isinstance(instance, OutpostServiceConnection): LOGGER.debug("triggering ServiceConnection state update", instance=instance)