sources/ldap: fix more errors (#6191)
This commit is contained in:
parent
8828eefbe4
commit
657c17a12f
|
@ -30,12 +30,15 @@ CACHE_KEY_PREFIX = "goauthentik.io/sources/ldap/page/"
|
||||||
def ldap_sync_all():
|
def ldap_sync_all():
|
||||||
"""Sync all sources"""
|
"""Sync all sources"""
|
||||||
for source in LDAPSource.objects.filter(enabled=True):
|
for source in LDAPSource.objects.filter(enabled=True):
|
||||||
ldap_sync_single(source)
|
ldap_sync_single(source.pk)
|
||||||
|
|
||||||
|
|
||||||
@CELERY_APP.task()
|
@CELERY_APP.task()
|
||||||
def ldap_sync_single(source: LDAPSource):
|
def ldap_sync_single(source_pk: str):
|
||||||
"""Sync a single source"""
|
"""Sync a single source"""
|
||||||
|
source: LDAPSource = LDAPSource.objects.filter(pk=source_pk).first()
|
||||||
|
if not source:
|
||||||
|
return
|
||||||
task = chain(
|
task = chain(
|
||||||
# User and group sync can happen at once, they have no dependencies on each other
|
# User and group sync can happen at once, they have no dependencies on each other
|
||||||
group(
|
group(
|
||||||
|
@ -71,9 +74,8 @@ def ldap_sync_paginator(source: LDAPSource, sync: type[BaseLDAPSynchronizer]) ->
|
||||||
def ldap_sync(self: MonitoredTask, source_pk: str, sync_class: str, page_cache_key: str):
|
def ldap_sync(self: MonitoredTask, source_pk: str, sync_class: str, page_cache_key: str):
|
||||||
"""Synchronization of an LDAP Source"""
|
"""Synchronization of an LDAP Source"""
|
||||||
self.result_timeout_hours = int(CONFIG.y("ldap.task_timeout_hours"))
|
self.result_timeout_hours = int(CONFIG.y("ldap.task_timeout_hours"))
|
||||||
try:
|
source: LDAPSource = LDAPSource.objects.filter(pk=source_pk).first()
|
||||||
source: LDAPSource = LDAPSource.objects.get(pk=source_pk)
|
if not source:
|
||||||
except LDAPSource.DoesNotExist:
|
|
||||||
# Because the source couldn't be found, we don't have a UID
|
# Because the source couldn't be found, we don't have a UID
|
||||||
# to set the state with
|
# to set the state with
|
||||||
return
|
return
|
||||||
|
|
Reference in New Issue