Skip to content

Commit

Permalink
sources/ldap: lint changed files
Browse files Browse the repository at this point in the history
  • Loading branch information
krejcar25 committed Jan 14, 2025
1 parent 1211310 commit a74b15d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
class Migration(migrations.Migration):

dependencies = [
("authentik_sources_ldap", "0006_rename_ldappropertymapping_ldapsourcepropertymapping_and_more"),
(
"authentik_sources_ldap",
"0006_rename_ldappropertymapping_ldapsourcepropertymapping_and_more",
),
]

operations = [
Expand Down
8 changes: 3 additions & 5 deletions authentik/sources/ldap/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,9 @@ class LDAPSource(Source):
lookup_groups_from_user = models.BooleanField(
default=False,
help_text=_(
(
"Lookup group membership based on a user attribute instead of a group attribute."
"This allows nested group resolution on systems like FreeIPA and Active Directory"
)
)
"Lookup group membership based on a user attribute instead of a group attribute."
"This allows nested group resolution on systems like FreeIPA and Active Directory"
),
)

@property
Expand Down
11 changes: 5 additions & 6 deletions authentik/sources/ldap/sync/membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ def get_objects(self, **kwargs) -> Generator:
if not self._source.sync_groups:
self.message("Group syncing is disabled for this Source")
return iter(())


# If we are looking up groups from users, we don't need to fetch the group membership field
attributes = [self._source.object_uniqueness_field, LDAP_DISTINGUISHED_NAME]
if not self._source.lookup_groups_from_user: # If we are looking up groups from users, we don't need to fetch the group membership field
if not self._source.lookup_groups_from_user:
attributes.append(self._source.group_membership_field)

return self.search_paginator(
search_base=self.base_dn_groups,
search_filter=self._source.group_object_filter,
Expand All @@ -55,9 +56,7 @@ def sync(self, page_data: list) -> int:
search_base=self.base_dn_users,
search_filter=group_filter,
search_scope=SUBTREE,
attributes=[
self._source.object_uniqueness_field
]
attributes=[self._source.object_uniqueness_field],
)
members = []
for group_member in group_members:
Expand Down
4 changes: 3 additions & 1 deletion web/src/admin/sources/ldap/LDAPSourceForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,9 @@ export class LDAPSourceForm extends BaseSourceForm<LDAPSource> {
<i class="fas fa-check" aria-hidden="true"></i>
</span>
</span>
<span class="pf-c-switch__label">${msg("Lookup using user attribute")}</span>
<span class="pf-c-switch__label"
>${msg("Lookup using user attribute")}</span
>
</label>
<p class="pf-c-form__helper-text">
${msg(
Expand Down

0 comments on commit a74b15d

Please sign in to comment.