From e4086609f7abc378595864aa375c9cb9497828b6 Mon Sep 17 00:00:00 2001 From: Jean-Yves LEBLEU Date: Mon, 9 May 2022 18:44:09 +0200 Subject: [PATCH] fix: force username to lower case when creating LDAP user --- api/login.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/api/login.go b/api/login.go index 16bcc178..79d0f5a0 100644 --- a/api/login.go +++ b/api/login.go @@ -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),