0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2025-03-11 02:17:43 -05:00

Merge pull request #27 from rchincha/ldap-fix

auth: add LDAP support
This commit is contained in:
Ramkumar Chinchani 2019-09-20 14:41:34 -07:00 committed by GitHub
commit d4366d501b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 16 deletions

View file

@ -18,5 +18,6 @@ var (
ErrBadCACert = errors.New("tls: invalid ca cert") ErrBadCACert = errors.New("tls: invalid ca cert")
ErrBadUser = errors.New("ldap: non-existent user") ErrBadUser = errors.New("ldap: non-existent user")
ErrEntriesExceeded = errors.New("ldap: too many entries returned") ErrEntriesExceeded = errors.New("ldap: too many entries returned")
ErrLDAPEmptyPassphrase = errors.New("ldap: empty passphrase")
ErrLDAPConfig = errors.New("config: invalid LDAP configuration") ErrLDAPConfig = errors.New("config: invalid LDAP configuration")
) )

View file

@ -71,6 +71,11 @@ func (lc *LDAPClient) Connect() error {
// Authenticate authenticates the user against the ldap backend. // Authenticate authenticates the user against the ldap backend.
func (lc *LDAPClient) Authenticate(username, password string) (bool, map[string]string, error) { func (lc *LDAPClient) Authenticate(username, password string) (bool, map[string]string, error) {
if password == "" {
// RFC 4513 section 5.1.2
return false, nil, errors.ErrLDAPEmptyPassphrase
}
err := lc.Connect() err := lc.Connect()
if err != nil { if err != nil {
return false, nil, err return false, nil, err