Fix empty ssh key importing in ldap (#5984)

release/v1.15
zeripath 2019-02-07 02:38:28 +00:00 committed by techknowlogick
parent 44d6a904d3
commit cc48c12d8f
1 changed files with 6 additions and 3 deletions

View File

@ -1501,9 +1501,12 @@ func synchronizeLdapSSHPublicKeys(usr *User, s *LoginSource, SSHPublicKeys []str
// Get Public Keys from LDAP and skip duplicate keys // Get Public Keys from LDAP and skip duplicate keys
var ldapKeys []string var ldapKeys []string
for _, v := range SSHPublicKeys { for _, v := range SSHPublicKeys {
ldapKey := strings.Join(strings.Split(v, " ")[:2], " ") sshKeySplit := strings.Split(v, " ")
if !util.ExistsInSlice(ldapKey, ldapKeys) { if len(sshKeySplit) > 1 {
ldapKeys = append(ldapKeys, ldapKey) ldapKey := strings.Join(sshKeySplit[:2], " ")
if !util.ExistsInSlice(ldapKey, ldapKeys) {
ldapKeys = append(ldapKeys, ldapKey)
}
} }
} }