From 10fe67e08d5a4c91079e4d6f914e9ca4b85a6cf4 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 14 Dec 2021 22:53:14 +0100 Subject: [PATCH] sources/ldap: fix incorrect task names being referenced, use source native slug Signed-off-by: Jens Langhammer --- authentik/sources/ldap/api.py | 5 +++-- authentik/sources/ldap/tasks.py | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/authentik/sources/ldap/api.py b/authentik/sources/ldap/api.py index 7b1413c4b..62c8478ed 100644 --- a/authentik/sources/ldap/api.py +++ b/authentik/sources/ldap/api.py @@ -1,7 +1,6 @@ """Source API Views""" from typing import Any -from django.utils.text import slugify from django_filters.filters import AllValuesMultipleFilter from django_filters.filterset import FilterSet from drf_spectacular.types import OpenApiTypes @@ -110,7 +109,9 @@ class LDAPSourceViewSet(UsedByMixin, ModelViewSet): GroupLDAPSynchronizer, MembershipLDAPSynchronizer, ]: - task = TaskInfo.by_name(f"ldap_sync_{slugify(source.name)}-{sync_class.__name__}") + task = TaskInfo.by_name( + f"ldap_sync_{source.slug}_{sync_class.__name__.replace('LDAPSynchronizer', '').lower()}" + ) if task: results.append(task) return Response(TaskSerializer(results, many=True).data) diff --git a/authentik/sources/ldap/tasks.py b/authentik/sources/ldap/tasks.py index d83786e2f..f29eda623 100644 --- a/authentik/sources/ldap/tasks.py +++ b/authentik/sources/ldap/tasks.py @@ -1,5 +1,4 @@ """LDAP Sync tasks""" -from django.utils.text import slugify from ldap3.core.exceptions import LDAPException from structlog.stdlib import get_logger @@ -39,7 +38,7 @@ def ldap_sync(self: MonitoredTask, source_pk: str, sync_class: str): # to set the state with return sync = path_to_class(sync_class) - self.set_uid(f"{slugify(source.name)}_{sync.__name__.replace('LDAPSynchronizer', '').lower()}") + self.set_uid(f"{source.slug}_{sync.__name__.replace('LDAPSynchronizer', '').lower()}") try: sync_inst = sync(source) count = sync_inst.sync()