mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-22 16:48:30 +01:00
do not return error when ldap bind failed
This commit is contained in:
parent
ee93627391
commit
2f6dd6f102
@ -79,7 +79,8 @@ func (l *Auth) Authenticate(m models.AuthModel) (*models.User, error) {
|
||||
|
||||
log.Debugf("username: %s, dn: %s", u.Username, dn)
|
||||
if err := ldapUtils.Bind(ldapConfs, dn, m.Password); err != nil {
|
||||
return nil, fmt.Errorf("Failed to bind user, username: %s, dn: %s, error: %v", u.Username, dn, err)
|
||||
log.Warningf("Failed to bind user, username: %s, dn: %s, error: %v", u.Username, dn, err)
|
||||
return nil, nil
|
||||
}
|
||||
exist, err := dao.UserExists(u, "username")
|
||||
if err != nil {
|
||||
|
@ -124,8 +124,11 @@ func TestAuthenticate(t *testing.T) {
|
||||
}
|
||||
person.Principal = "test"
|
||||
person.Password = "1"
|
||||
_, err = auth.Authenticate(person)
|
||||
if err == nil {
|
||||
t.Errorf("Expected error for wrong password")
|
||||
user, err = auth.Authenticate(person)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected ldap error: %v", err)
|
||||
}
|
||||
if user != nil {
|
||||
t.Errorf("Nil user expected for wrong password")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user