Merge pull request #925 from jlebleu/915-Unable_to_log_twice_using_LDAP

fix: force username to lower case when creating LDAP user
This commit is contained in:
Denis Gukov 2022-05-09 22:38:47 +05:00 committed by GitHub
commit 6a4444b645
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,13 +3,14 @@ package api
import (
"crypto/tls"
"fmt"
"github.com/ansible-semaphore/semaphore/api/helpers"
"github.com/ansible-semaphore/semaphore/db"
"github.com/go-ldap/ldap/v3"
"net/http"
"strings"
"time"
"github.com/ansible-semaphore/semaphore/api/helpers"
"github.com/ansible-semaphore/semaphore/db"
"github.com/go-ldap/ldap/v3"
log "github.com/Sirupsen/logrus"
"github.com/ansible-semaphore/semaphore/util"
@ -84,7 +85,7 @@ func tryFindLDAPUser(username, password string) (*db.User, error) {
}
ldapUser := db.User{
Username: sr.Entries[0].GetAttributeValue(util.Config.LdapMappings.UID),
Username: strings.ToLower(sr.Entries[0].GetAttributeValue(util.Config.LdapMappings.UID)),
Created: time.Now(),
Name: sr.Entries[0].GetAttributeValue(util.Config.LdapMappings.CN),
Email: sr.Entries[0].GetAttributeValue(util.Config.LdapMappings.Mail),