feat(ldap): make member id attribute configurable

This commit is contained in:
kolaente 2025-03-19 22:15:50 +01:00
parent 84cbd25e67
commit f4b9a9cccd
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
3 changed files with 9 additions and 2 deletions

View File

@ -799,6 +799,11 @@
"key": "displayname", "key": "displayname",
"default_value": "displayName", "default_value": "displayName",
"comment": "The LDAP attribute used to set the displayed name in Vikunja." "comment": "The LDAP attribute used to set the displayed name in Vikunja."
},
{
"key": "memberid",
"default_value": "member",
"comment": "The LDAP attribute used to check group membership of a team in Vikunja. Only used when groups are synced to Vikunja."
} }
] ]
} }

View File

@ -94,6 +94,7 @@ const (
AuthLdapAttributeUsername Key = `auth.ldap.attribute.username` AuthLdapAttributeUsername Key = `auth.ldap.attribute.username`
AuthLdapAttributeEmail Key = `auth.ldap.attribute.email` AuthLdapAttributeEmail Key = `auth.ldap.attribute.email`
AuthLdapAttributeDisplayname Key = `auth.ldap.attribute.displayname` AuthLdapAttributeDisplayname Key = `auth.ldap.attribute.displayname`
AuthLdapAttributeMemberID Key = `auth.ldap.attribute.memberid`
LegalImprintURL Key = `legal.imprinturl` LegalImprintURL Key = `legal.imprinturl`
LegalPrivacyURL Key = `legal.privacyurl` LegalPrivacyURL Key = `legal.privacyurl`
@ -360,6 +361,7 @@ func InitDefaultConfig() {
AuthLdapAttributeUsername.setDefault("uid") AuthLdapAttributeUsername.setDefault("uid")
AuthLdapAttributeEmail.setDefault("mail") AuthLdapAttributeEmail.setDefault("mail")
AuthLdapAttributeDisplayname.setDefault("displayName") AuthLdapAttributeDisplayname.setDefault("displayName")
AuthLdapAttributeMemberID.setDefault("member")
// Database // Database
DatabaseType.setDefault("sqlite") DatabaseType.setDefault("sqlite")

View File

@ -231,7 +231,7 @@ func syncUserGroups(l *ldap.Conn, u *user.User, userdn string) (err error) {
[]string{ []string{
"dn", "dn",
"cn", "cn",
"member", config.AuthLdapAttributeMemberID.GetString(),
"description", "description",
}, },
nil, nil,
@ -247,7 +247,7 @@ func syncUserGroups(l *ldap.Conn, u *user.User, userdn string) (err error) {
for _, group := range sr.Entries { for _, group := range sr.Entries {
groupName := group.GetAttributeValue("cn") groupName := group.GetAttributeValue("cn")
members := group.GetAttributeValues("member") members := group.GetAttributeValues(config.AuthLdapAttributeMemberID.GetString())
description := group.GetAttributeValue("description") description := group.GetAttributeValue("description")
log.Debugf("Group %s has %d members", groupName, len(members)) log.Debugf("Group %s has %d members", groupName, len(members))