sources/ldap: fix missing search attribute (#11125)
* unrelated Signed-off-by: Jens Langhammer <jens@goauthentik.io> * sources/ldap: fix ldap sync not requesting uniqueness attribute Signed-off-by: Jens Langhammer <jens@goauthentik.io> * check object_uniqueness_field for none Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -3,7 +3,7 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.db.models.signals import post_save, pre_save
|
from django.db.models.signals import post_delete, post_save, pre_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.utils.timezone import get_current_timezone
|
from django.utils.timezone import get_current_timezone
|
||||||
|
|
||||||
@ -27,3 +27,9 @@ def post_save_license(sender: type[License], instance: License, **_):
|
|||||||
"""Trigger license usage calculation when license is saved"""
|
"""Trigger license usage calculation when license is saved"""
|
||||||
cache.delete(CACHE_KEY_ENTERPRISE_LICENSE)
|
cache.delete(CACHE_KEY_ENTERPRISE_LICENSE)
|
||||||
enterprise_update_usage.delay()
|
enterprise_update_usage.delay()
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(post_delete, sender=License)
|
||||||
|
def post_delete_license(sender: type[License], instance: License, **_):
|
||||||
|
"""Clear license cache when license is deleted"""
|
||||||
|
cache.delete(CACHE_KEY_ENTERPRISE_LICENSE)
|
||||||
|
|||||||
@ -38,7 +38,11 @@ class GroupLDAPSynchronizer(BaseLDAPSynchronizer):
|
|||||||
search_base=self.base_dn_groups,
|
search_base=self.base_dn_groups,
|
||||||
search_filter=self._source.group_object_filter,
|
search_filter=self._source.group_object_filter,
|
||||||
search_scope=SUBTREE,
|
search_scope=SUBTREE,
|
||||||
attributes=[ALL_ATTRIBUTES, ALL_OPERATIONAL_ATTRIBUTES],
|
attributes=[
|
||||||
|
ALL_ATTRIBUTES,
|
||||||
|
ALL_OPERATIONAL_ATTRIBUTES,
|
||||||
|
self._source.object_uniqueness_field,
|
||||||
|
],
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -53,9 +57,9 @@ class GroupLDAPSynchronizer(BaseLDAPSynchronizer):
|
|||||||
continue
|
continue
|
||||||
attributes = group.get("attributes", {})
|
attributes = group.get("attributes", {})
|
||||||
group_dn = flatten(flatten(group.get("entryDN", group.get("dn"))))
|
group_dn = flatten(flatten(group.get("entryDN", group.get("dn"))))
|
||||||
if self._source.object_uniqueness_field not in attributes:
|
if not attributes.get(self._source.object_uniqueness_field):
|
||||||
self.message(
|
self.message(
|
||||||
f"Cannot find uniqueness field in attributes: '{group_dn}'",
|
f"Uniqueness field not found/not set in attributes: '{group_dn}'",
|
||||||
attributes=attributes.keys(),
|
attributes=attributes.keys(),
|
||||||
dn=group_dn,
|
dn=group_dn,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -40,7 +40,11 @@ class UserLDAPSynchronizer(BaseLDAPSynchronizer):
|
|||||||
search_base=self.base_dn_users,
|
search_base=self.base_dn_users,
|
||||||
search_filter=self._source.user_object_filter,
|
search_filter=self._source.user_object_filter,
|
||||||
search_scope=SUBTREE,
|
search_scope=SUBTREE,
|
||||||
attributes=[ALL_ATTRIBUTES, ALL_OPERATIONAL_ATTRIBUTES],
|
attributes=[
|
||||||
|
ALL_ATTRIBUTES,
|
||||||
|
ALL_OPERATIONAL_ATTRIBUTES,
|
||||||
|
self._source.object_uniqueness_field,
|
||||||
|
],
|
||||||
**kwargs,
|
**kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -55,9 +59,9 @@ class UserLDAPSynchronizer(BaseLDAPSynchronizer):
|
|||||||
continue
|
continue
|
||||||
attributes = user.get("attributes", {})
|
attributes = user.get("attributes", {})
|
||||||
user_dn = flatten(user.get("entryDN", user.get("dn")))
|
user_dn = flatten(user.get("entryDN", user.get("dn")))
|
||||||
if self._source.object_uniqueness_field not in attributes:
|
if not attributes.get(self._source.object_uniqueness_field):
|
||||||
self.message(
|
self.message(
|
||||||
f"Cannot find uniqueness field in attributes: '{user_dn}'",
|
f"Uniqueness field not found/not set in attributes: '{user_dn}'",
|
||||||
attributes=attributes.keys(),
|
attributes=attributes.keys(),
|
||||||
dn=user_dn,
|
dn=user_dn,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -59,7 +59,7 @@ const runningState: State = {
|
|||||||
};
|
};
|
||||||
const errorState: State = {
|
const errorState: State = {
|
||||||
state: "error",
|
state: "error",
|
||||||
label: msg("Authentik was unable to save this application:"),
|
label: msg("authentik was unable to save this application:"),
|
||||||
icon: ["fa-times-circle", "pf-m-danger"],
|
icon: ["fa-times-circle", "pf-m-danger"],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user