sources/ldap: fix ldap_sync cli command not running in foreground (#6325)
closes #6317 Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
82935ddf11
commit
9b7c30d44c
|
@ -3,7 +3,10 @@ from django.core.management.base import BaseCommand
|
||||||
from structlog.stdlib import get_logger
|
from structlog.stdlib import get_logger
|
||||||
|
|
||||||
from authentik.sources.ldap.models import LDAPSource
|
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()
|
LOGGER = get_logger()
|
||||||
|
|
||||||
|
@ -20,4 +23,10 @@ class Command(BaseCommand):
|
||||||
if not source:
|
if not source:
|
||||||
LOGGER.warning("Source does not exist", slug=source_slug)
|
LOGGER.warning("Source does not exist", slug=source_slug)
|
||||||
continue
|
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()
|
||||||
|
|
|
@ -49,7 +49,7 @@ class UserLDAPSynchronizer(BaseLDAPSynchronizer):
|
||||||
uniq = self._flatten(attributes[self._source.object_uniqueness_field])
|
uniq = self._flatten(attributes[self._source.object_uniqueness_field])
|
||||||
try:
|
try:
|
||||||
defaults = self.build_user_properties(user_dn, **attributes)
|
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:
|
if "username" not in defaults:
|
||||||
raise IntegrityError("Username was not set by propertymappings")
|
raise IntegrityError("Username was not set by propertymappings")
|
||||||
ak_user, created = self.update_or_create_attributes(
|
ak_user, created = self.update_or_create_attributes(
|
||||||
|
|
|
@ -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
|
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
|
or, for Kubernetes, run
|
||||||
|
|
Reference in New Issue