Fix empty ssh key importing in ldap (#5984)
This commit is contained in:
parent
44d6a904d3
commit
cc48c12d8f
|
@ -1501,11 +1501,14 @@ 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 len(sshKeySplit) > 1 {
|
||||||
|
ldapKey := strings.Join(sshKeySplit[:2], " ")
|
||||||
if !util.ExistsInSlice(ldapKey, ldapKeys) {
|
if !util.ExistsInSlice(ldapKey, ldapKeys) {
|
||||||
ldapKeys = append(ldapKeys, ldapKey)
|
ldapKeys = append(ldapKeys, ldapKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if Public Key sync is needed
|
// Check if Public Key sync is needed
|
||||||
if util.IsEqualSlice(giteaKeys, ldapKeys) {
|
if util.IsEqualSlice(giteaKeys, ldapKeys) {
|
||||||
|
|
Loading…
Reference in New Issue