Skip to content

Commit 22cda19

Browse files
theangryangeltorkelo
authored andcommitted
Apply EscapeFilter to username to address grafana#5121 (grafana#5279)
1 parent d1c06a9 commit 22cda19

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/login/ldap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ func (a *ldapAuther) searchForUser(username string) (*ldapUserInfo, error) {
291291
a.server.Attr.Name,
292292
a.server.Attr.MemberOf,
293293
},
294-
Filter: strings.Replace(a.server.SearchFilter, "%s", username, -1),
294+
Filter: strings.Replace(a.server.SearchFilter, "%s", ldap.EscapeFilter(username), -1),
295295
}
296296

297297
searchResult, err = a.conn.Search(&searchReq)
@@ -324,7 +324,7 @@ func (a *ldapAuther) searchForUser(username string) (*ldapUserInfo, error) {
324324
if a.server.GroupSearchFilterUserAttribute == "" {
325325
filter_replace = getLdapAttr(a.server.Attr.Username, searchResult)
326326
}
327-
filter := strings.Replace(a.server.GroupSearchFilter, "%s", filter_replace, -1)
327+
filter := strings.Replace(a.server.GroupSearchFilter, "%s", ldap.EscapeFilter(filter_replace), -1)
328328

329329
if ldapCfg.VerboseLogging {
330330
log.Info("LDAP: Searching for user's groups: %s", filter)

0 commit comments

Comments
 (0)