Skip to content

Commit cc48c12

Browse files
zeripathtechknowlogick
authored andcommitted
Fix empty ssh key importing in ldap (#5984)
1 parent 44d6a90 commit cc48c12

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
@@ -1501,9 +1501,12 @@ func synchronizeLdapSSHPublicKeys(usr *User, s *LoginSource, SSHPublicKeys []str
15011501
// Get Public Keys from LDAP and skip duplicate keys
15021502
var ldapKeys []string
15031503
for _, v := range SSHPublicKeys {
1504-
ldapKey := strings.Join(strings.Split(v, " ")[:2], " ")
1505-
if !util.ExistsInSlice(ldapKey, ldapKeys) {
1506-
ldapKeys = append(ldapKeys, ldapKey)
1504+
sshKeySplit := strings.Split(v, " ")
1505+
if len(sshKeySplit) > 1 {
1506+
ldapKey := strings.Join(sshKeySplit[:2], " ")
1507+
if !util.ExistsInSlice(ldapKey, ldapKeys) {
1508+
ldapKeys = append(ldapKeys, ldapKey)
1509+
}
15071510
}
15081511
}
15091512

0 commit comments

Comments
 (0)