Skip to content

Commit e0f6301

Browse files
authored
allow LDAP mapping values to be lowercased (#348)
Add the ability to lowercase values when creating label mappings from LDAP attributes. In the example the groups that the user is a member of could be mixed case which would make an ACL like: match: { account: "/.+/", name: "${labels:groups}/*" } Not possible. But with this change and the example applied it would be possible.
1 parent 1111a3e commit e0f6301

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

auth_server/authn/ldap_auth.go

+6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
type LabelMap struct {
3333
Attribute string `yaml:"attribute,omitempty"`
3434
ParseCN bool `yaml:"parse_cn,omitempty"`
35+
LowerCase bool `yaml:"lower_case",omitempty"`
3536
}
3637

3738
type LDAPAuthConfig struct {
@@ -299,6 +300,11 @@ func (la *LDAPAuth) getLabelsFromMap(attrMap map[string][]string) (map[string][]
299300
mappingValues[i] = cn
300301
}
301302
}
303+
if mapping.LowerCase {
304+
for i, value := range mappingValues {
305+
mappingValues[i] = strings.ToLower(value)
306+
}
307+
}
302308
labels[key] = mappingValues
303309
}
304310
}

examples/reference.yml

+2
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ ldap_auth:
260260
attribute: memberOf
261261
# Special handling to simplify the values to just the common name
262262
parse_cn: true
263+
# lower case the value
264+
lower_case: true
263265

264266
mongo_auth:
265267
# Essentially all options are described here: https://godoc.org/gopkg.in/mgo.v2#DialInfo

0 commit comments

Comments
 (0)