sources/ldap: add default property mapping to mirror directory structure (#6990)

* sources/ldap: add default property mapping to mirror directory structure

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* add tests

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* adjust name

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

---------

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L
2023-09-26 18:55:33 +02:00
committed by GitHub
parent 017771ddf7
commit 90aa5409cd
4 changed files with 27 additions and 3 deletions

View File

@ -4,6 +4,27 @@ metadata:
blueprints.goauthentik.io/system: "true"
name: System - LDAP Source - Mappings
entries:
- identifiers:
managed: goauthentik.io/sources/ldap/default-dn-path
model: authentik_sources_ldap.ldappropertymapping
attrs:
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("=")
# Ignore elements from the Root DSE and the canonical name of the object
if attr.lower() in ["cn", "dc"]:
continue
path_elements.append(value)
path_elements.reverse()
path = source.get_user_path()
if len(path_elements) > 0:
path = f"{path}/{'/'.join(path_elements)}"
return path
- identifiers:
managed: goauthentik.io/sources/ldap/default-name
model: authentik_sources_ldap.ldappropertymapping