connector/ldap: add multiple user to group mapping
Add an ability to fetch user's membership from
groups of a different type by specifying multiple
group attribute to user attribute value matchers
in the Dex config:
userMatchers:
- userAttr: uid
groupAttr: memberUid
- userAttr: DN
groupAttr: member
In other words the user's groups can be fetched now from
ldap structure similar to the following:
dn: cn=john,ou=People,dc=example,dc=org
objectClass: person
objectClass: inetOrgPerson
sn: doe
cn: john
uid: johndoe
mail: johndoe@example.com
userpassword: bar
dn: cn=qa,ou=Groups,ou=Portland,dc=example,dc=org
objectClass: groupOfNames
cn: qa
member: cn=john,ou=People,dc=example,dc=org
dn: cn=logger,ou=UnixGroups,ou=Portland,dc=example,dc=org
objectClass: posixGroup
gidNumber: 1000
cn: logger
memberUid: johndoe
Signed-off-by: Vitaliy Dmitriev <vi7alya@gmail.com>
# Optional filter to apply when searching the directory.
# Optional filter to apply when searching the directory.
filter: "(objectClass=group)"
filter: "(objectClass=group)"
# Following two fields are used to match a user to a group. It adds an additional
# Following list contains field pairs that are used to match a user to a group. It adds an additional
# requirement to the filter that an attribute in the group must match the user's
# requirement to the filter that an attribute in the group must match the user's
# attribute value.
# attribute value.
userAttr: uid
userMatchers:
groupAttr: member
- userAttr: uid
groupAttr: member
# Represents group name.
# Represents group name.
nameAttr: name
nameAttr: name
@ -215,8 +216,9 @@ groupSearch:
# The group search needs to match the "uid" attribute on
# The group search needs to match the "uid" attribute on
# the user with the "memberUid" attribute on the group.
# the user with the "memberUid" attribute on the group.
userAttr: uid
userMatchers:
groupAttr: memberUid
- userAttr: uid
groupAttr: memberUid
# Unique name of the group.
# Unique name of the group.
nameAttr: cn
nameAttr: cn
@ -242,8 +244,27 @@ groupSearch:
# Optional filter to apply when searching the directory.
# Optional filter to apply when searching the directory.
filter: "(objectClass=group)"
filter: "(objectClass=group)"
userAttr: DN # Use "DN" here not "uid"
userMatchers:
groupAttr: member
- userAttr: DN # Use "DN" here not "uid"
groupAttr: member
nameAttr: name
```
There are cases when different types (objectClass) of groups use different attributes to keep a list of members. Below is an example of group query for such case:
```yaml
groupSearch:
baseDN: cn=groups,cn=compat,dc=example,dc=com
# Optional filter to search for different group types