Skip to content

Commit baf6cc4

Browse files
3l0wwxiaoguang
authored andcommitted
Move user password verification after checking his groups on ldap auth (go-gitea#19587)
In case the binded user can not access its own attributes. Signed-off-by: Gwilherm Folliot <[email protected]> Co-authored-by: wxiaoguang <[email protected]>
1 parent 4591a22 commit baf6cc4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

services/auth/source/ldap/source_search.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -433,14 +433,6 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul
433433
isRestricted = checkRestricted(l, ls, userDN)
434434
}
435435

436-
if !directBind && ls.AttributesInBind {
437-
// binds user (checking password) after looking-up attributes in BindDN context
438-
err = bindUser(l, userDN, passwd)
439-
if err != nil {
440-
return nil
441-
}
442-
}
443-
444436
if isAtributeAvatarSet {
445437
Avatar = sr.Entries[0].GetRawAttributeValue(ls.AttributeAvatar)
446438
}
@@ -451,6 +443,14 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul
451443
teamsToAdd, teamsToRemove = ls.getMappedMemberships(l, uid)
452444
}
453445

446+
if !directBind && ls.AttributesInBind {
447+
// binds user (checking password) after looking-up attributes in BindDN context
448+
err = bindUser(l, userDN, passwd)
449+
if err != nil {
450+
return nil
451+
}
452+
}
453+
454454
return &SearchResult{
455455
LowerName: strings.ToLower(username),
456456
Username: username,

0 commit comments

Comments
 (0)