From 6f3dc2eafd6391e53a8d7c2bf318c2ebb501cc78 Mon Sep 17 00:00:00 2001 From: Jens L Date: Fri, 19 Apr 2024 14:44:48 +0200 Subject: [PATCH] sources/ldap: fix default blueprint for mapping user DN to path (#9355) * sources/ldap: fix default blueprint for mapping user DN to path Signed-off-by: Jens Langhammer * fix tests Signed-off-by: Jens Langhammer --------- Signed-off-by: Jens Langhammer --- authentik/sources/ldap/tests/mock_ad.py | 4 ++-- authentik/sources/ldap/tests/test_auth.py | 2 +- blueprints/system/sources-ldap.yaml | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/authentik/sources/ldap/tests/mock_ad.py b/authentik/sources/ldap/tests/mock_ad.py index b0914bda4f..9c0be2109c 100644 --- a/authentik/sources/ldap/tests/mock_ad.py +++ b/authentik/sources/ldap/tests/mock_ad.py @@ -34,7 +34,7 @@ def mock_ad_connection(password: str) -> Connection: "objectSid": "unique-test-group", "objectClass": "group", "distinguishedName": "cn=group1,ou=groups,dc=goauthentik,dc=io", - "member": ["cn=user0,ou=users,dc=goauthentik,dc=io"], + "member": ["cn=user,ou=users,dc=goauthentik,dc=io"], }, ) # Group without SID @@ -47,7 +47,7 @@ def mock_ad_connection(password: str) -> Connection: }, ) connection.strategy.add_entry( - "cn=user0,ou=users,dc=goauthentik,dc=io", + "cn=user0,ou=foo,ou=users,dc=goauthentik,dc=io", { "userPassword": password, "sAMAccountName": "user0_sn", diff --git a/authentik/sources/ldap/tests/test_auth.py b/authentik/sources/ldap/tests/test_auth.py index 48f04bf293..0e634e3a37 100644 --- a/authentik/sources/ldap/tests/test_auth.py +++ b/authentik/sources/ldap/tests/test_auth.py @@ -55,7 +55,7 @@ class LDAPSyncTests(TestCase): ) connection.assert_called_with( connection_kwargs={ - "user": "cn=user0,ou=users,dc=goauthentik,dc=io", + "user": "cn=user0,ou=foo,ou=users,dc=goauthentik,dc=io", "password": LDAP_PASSWORD, } ) diff --git a/blueprints/system/sources-ldap.yaml b/blueprints/system/sources-ldap.yaml index dbf8891e7b..66e1462eee 100644 --- a/blueprints/system/sources-ldap.yaml +++ b/blueprints/system/sources-ldap.yaml @@ -11,7 +11,6 @@ entries: name: "authentik default LDAP Mapping: DN to User Path" object_field: "path" expression: | - dn = ldap.get("distinguishedName") path_elements = [] for pair in dn.split(","): attr, _, value = pair.partition("=")