Skip to content

Commit b0b574f

Browse files
zeripathlafriks
authored andcommitted
Fix empty ssh key importing in ldap (#5984) (#6009)
1 parent d269179 commit b0b574f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

models/user.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,9 +1461,12 @@ func synchronizeLdapSSHPublicKeys(usr *User, s *LoginSource, SSHPublicKeys []str
14611461
// Get Public Keys from LDAP and skip duplicate keys
14621462
var ldapKeys []string
14631463
for _, v := range SSHPublicKeys {
1464-
ldapKey := strings.Join(strings.Split(v, " ")[:2], " ")
1465-
if !util.ExistsInSlice(ldapKey, ldapKeys) {
1466-
ldapKeys = append(ldapKeys, ldapKey)
1464+
sshKeySplit := strings.Split(v, " ")
1465+
if len(sshKeySplit) > 1 {
1466+
ldapKey := strings.Join(sshKeySplit[:2], " ")
1467+
if !util.ExistsInSlice(ldapKey, ldapKeys) {
1468+
ldapKeys = append(ldapKeys, ldapKey)
1469+
}
14671470
}
14681471
}
14691472

0 commit comments

Comments
 (0)