@ -29,6 +29,7 @@ import (
"github.com/go-xorm/xorm"
"github.com/go-xorm/xorm"
"github.com/nfnt/resize"
"github.com/nfnt/resize"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/crypto/ssh"
"code.gitea.io/git"
"code.gitea.io/git"
api "code.gitea.io/sdk/gitea"
api "code.gitea.io/sdk/gitea"
@ -1454,7 +1455,8 @@ func deleteKeysMarkedForDeletion(keys []string) (bool, error) {
func addLdapSSHPublicKeys ( s * LoginSource , usr * User , SSHPublicKeys [ ] string ) bool {
func addLdapSSHPublicKeys ( s * LoginSource , usr * User , SSHPublicKeys [ ] string ) bool {
var sshKeysNeedUpdate bool
var sshKeysNeedUpdate bool
for _ , sshKey := range SSHPublicKeys {
for _ , sshKey := range SSHPublicKeys {
if strings . HasPrefix ( strings . ToLower ( sshKey ) , "ssh" ) {
_ , _ , _ , _ , err := ssh . ParseAuthorizedKey ( [ ] byte ( sshKey ) )
if err == nil {
sshKeyName := fmt . Sprintf ( "%s-%s" , s . Name , sshKey [ 0 : 40 ] )
sshKeyName := fmt . Sprintf ( "%s-%s" , s . Name , sshKey [ 0 : 40 ] )
if _ , err := AddPublicKey ( usr . ID , sshKeyName , sshKey , s . ID ) ; err != nil {
if _ , err := AddPublicKey ( usr . ID , sshKeyName , sshKey , s . ID ) ; err != nil {
log . Error ( 4 , "addLdapSSHPublicKeys[%s]: Error adding LDAP Public SSH Key for user %s: %v" , s . Name , usr . Name , err )
log . Error ( 4 , "addLdapSSHPublicKeys[%s]: Error adding LDAP Public SSH Key for user %s: %v" , s . Name , usr . Name , err )