Synchronize SSH keys on login with LDAP + Fix SQLite deadlock on ldap ssh key deletion (#5557)

* Synchronize SSH keys on login with LDAP

* BUG: Fix hang on sqlite during LDAP key deletion
This commit is contained in:
zeripath 2018-12-27 17:28:48 +00:00 committed by techknowlogick
parent 2058c362a8
commit 8bb0a6f425
4 changed files with 39 additions and 18 deletions

View file

@ -393,7 +393,13 @@ func LoginViaLDAP(user *User, login, password string, source *LoginSource, autoR
return nil, ErrUserNotExist{0, login, 0}
}
var isAttributeSSHPublicKeySet = len(strings.TrimSpace(source.LDAP().AttributeSSHPublicKey)) > 0
if !autoRegister {
if isAttributeSSHPublicKeySet && synchronizeLdapSSHPublicKeys(user, source, sr.SSHPublicKey) {
RewriteAllPublicKeys()
}
return user, nil
}
@ -421,7 +427,14 @@ func LoginViaLDAP(user *User, login, password string, source *LoginSource, autoR
IsActive: true,
IsAdmin: sr.IsAdmin,
}
return user, CreateUser(user)
err := CreateUser(user)
if err == nil && isAttributeSSHPublicKeySet && addLdapSSHPublicKeys(user, source, sr.SSHPublicKey) {
RewriteAllPublicKeys()
}
return user, err
}
// _________ __________________________