From 9b7c30d44c25efe0f061a0d4ce65ee67416cdc0b Mon Sep 17 00:00:00 2001 From: Jens L Date: Fri, 21 Jul 2023 13:03:06 +0200 Subject: [PATCH] sources/ldap: fix ldap_sync cli command not running in foreground (#6325) closes #6317 Signed-off-by: Jens Langhammer --- .../sources/ldap/management/commands/ldap_sync.py | 13 +++++++++++-- authentik/sources/ldap/sync/users.py | 2 +- website/docs/troubleshooting/ldap_source.md | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/authentik/sources/ldap/management/commands/ldap_sync.py b/authentik/sources/ldap/management/commands/ldap_sync.py index 15ea1c45a..eac5a32ef 100644 --- a/authentik/sources/ldap/management/commands/ldap_sync.py +++ b/authentik/sources/ldap/management/commands/ldap_sync.py @@ -3,7 +3,10 @@ from django.core.management.base import BaseCommand from structlog.stdlib import get_logger from authentik.sources.ldap.models import LDAPSource -from authentik.sources.ldap.tasks import ldap_sync_single +from authentik.sources.ldap.sync.groups import GroupLDAPSynchronizer +from authentik.sources.ldap.sync.membership import MembershipLDAPSynchronizer +from authentik.sources.ldap.sync.users import UserLDAPSynchronizer +from authentik.sources.ldap.tasks import ldap_sync_paginator LOGGER = get_logger() @@ -20,4 +23,10 @@ class Command(BaseCommand): if not source: LOGGER.warning("Source does not exist", slug=source_slug) continue - ldap_sync_single(source) + tasks = ( + ldap_sync_paginator(source, UserLDAPSynchronizer) + + ldap_sync_paginator(source, GroupLDAPSynchronizer) + + ldap_sync_paginator(source, MembershipLDAPSynchronizer) + ) + for task in tasks: + task() diff --git a/authentik/sources/ldap/sync/users.py b/authentik/sources/ldap/sync/users.py index c55d14517..4a67c1cdc 100644 --- a/authentik/sources/ldap/sync/users.py +++ b/authentik/sources/ldap/sync/users.py @@ -49,7 +49,7 @@ class UserLDAPSynchronizer(BaseLDAPSynchronizer): uniq = self._flatten(attributes[self._source.object_uniqueness_field]) try: defaults = self.build_user_properties(user_dn, **attributes) - self._logger.debug("Creating user with attributes", **defaults) + self._logger.debug("Writing user with attributes", **defaults) if "username" not in defaults: raise IntegrityError("Username was not set by propertymappings") ak_user, created = self.update_or_create_attributes( diff --git a/website/docs/troubleshooting/ldap_source.md b/website/docs/troubleshooting/ldap_source.md index 5d7450c69..196891751 100644 --- a/website/docs/troubleshooting/ldap_source.md +++ b/website/docs/troubleshooting/ldap_source.md @@ -5,7 +5,7 @@ title: Troubleshooting LDAP Synchronization To troubleshoot LDAP sources, you can run the command below to run a synchronization in the foreground and see any errors or warnings that might happen directly ``` -docker-compose run --rm server ldap_sync *slug of the source* +docker-compose run --rm worker ldap_sync *slug of the source* ``` or, for Kubernetes, run