From 02af96696459c8182faac6804033e02542dc79c7 Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Mon, 19 Aug 2019 00:52:32 +0300 Subject: [PATCH] LDAP: multildap + ldap integration (#18588) It seems `ldap` module introduced new error type of which multildap module didn't know about. This broke the multildap login logic Fixes #18491 Ref #18587 --- pkg/services/multildap/multildap.go | 5 ++++- pkg/services/multildap/multildap_test.go | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/services/multildap/multildap.go b/pkg/services/multildap/multildap.go index d2560d07e93..07c19b19fd5 100644 --- a/pkg/services/multildap/multildap.go +++ b/pkg/services/multildap/multildap.go @@ -19,6 +19,9 @@ var newLDAP = ldap.New // ErrInvalidCredentials is returned if username and password do not match var ErrInvalidCredentials = ldap.ErrInvalidCredentials +// ErrCouldNotFindUser is returned when username hasn't been found (not username+password) +var ErrCouldNotFindUser = ldap.ErrCouldNotFindUser + // ErrNoLDAPServers is returned when there is no LDAP servers specified var ErrNoLDAPServers = errors.New("No LDAP servers are configured") @@ -76,7 +79,7 @@ func (multiples *MultiLDAP) Login(query *models.LoginUserQuery) ( } // Continue if we couldn't find the user - if err == ErrInvalidCredentials { + if err == ErrCouldNotFindUser { continue } diff --git a/pkg/services/multildap/multildap_test.go b/pkg/services/multildap/multildap_test.go index f1ab230619e..03951122e2b 100644 --- a/pkg/services/multildap/multildap_test.go +++ b/pkg/services/multildap/multildap_test.go @@ -82,10 +82,10 @@ func TestMultiLDAP(t *testing.T) { teardown() }) - Convey("Should still call a second error for invalid cred error", func() { + Convey("Should still call a second error for invalid not found error", func() { mock := setup() - mock.loginErrReturn = ErrInvalidCredentials + mock.loginErrReturn = ErrCouldNotFindUser multi := New([]*ldap.ServerConfig{ {}, {},