@@ -84,7 +84,7 @@ func addKey(ctx context.Context, key *PublicKey) (err error) {
8484}
8585
8686// AddPublicKey adds new public key to database and authorized_keys file.
87- func AddPublicKey (ctx context.Context , ownerID int64 , name , content string , authSourceID int64 ) (* PublicKey , error ) {
87+ func AddPublicKey (ctx context.Context , ownerID int64 , name , content string , authSourceID int64 , verified bool ) (* PublicKey , error ) {
8888 log .Trace (content )
8989
9090 fingerprint , err := CalcFingerprint (content )
@@ -115,6 +115,7 @@ func AddPublicKey(ctx context.Context, ownerID int64, name, content string, auth
115115 Mode : perm .AccessModeWrite ,
116116 Type : KeyTypeUser ,
117117 LoginSourceID : authSourceID ,
118+ Verified : verified ,
118119 }
119120 if err = addKey (ctx , key ); err != nil {
120121 return nil , fmt .Errorf ("addKey: %w" , err )
@@ -298,7 +299,7 @@ func deleteKeysMarkedForDeletion(ctx context.Context, keys []string) (bool, erro
298299}
299300
300301// AddPublicKeysBySource add a users public keys. Returns true if there are changes.
301- func AddPublicKeysBySource (ctx context.Context , usr * user_model.User , s * auth.Source , sshPublicKeys []string ) bool {
302+ func AddPublicKeysBySource (ctx context.Context , usr * user_model.User , s * auth.Source , sshPublicKeys []string , verified bool ) bool {
302303 var sshKeysNeedUpdate bool
303304 for _ , sshKey := range sshPublicKeys {
304305 var err error
@@ -317,7 +318,7 @@ func AddPublicKeysBySource(ctx context.Context, usr *user_model.User, s *auth.So
317318 marshalled = marshalled [:len (marshalled )- 1 ]
318319 sshKeyName := fmt .Sprintf ("%s-%s" , s .Name , ssh .FingerprintSHA256 (out ))
319320
320- if _ , err := AddPublicKey (ctx , usr .ID , sshKeyName , marshalled , s .ID ); err != nil {
321+ if _ , err := AddPublicKey (ctx , usr .ID , sshKeyName , marshalled , s .ID , verified ); err != nil {
321322 if IsErrKeyAlreadyExist (err ) {
322323 log .Trace ("AddPublicKeysBySource[%s]: Public SSH Key %s already exists for user" , sshKeyName , usr .Name )
323324 } else {
@@ -336,7 +337,7 @@ func AddPublicKeysBySource(ctx context.Context, usr *user_model.User, s *auth.So
336337}
337338
338339// SynchronizePublicKeys updates a user's public keys. Returns true if there are changes.
339- func SynchronizePublicKeys (ctx context.Context , usr * user_model.User , s * auth.Source , sshPublicKeys []string ) bool {
340+ func SynchronizePublicKeys (ctx context.Context , usr * user_model.User , s * auth.Source , sshPublicKeys []string , verified bool ) bool {
340341 var sshKeysNeedUpdate bool
341342
342343 log .Trace ("synchronizePublicKeys[%s]: Handling Public SSH Key synchronization for user %s" , s .Name , usr .Name )
@@ -381,7 +382,7 @@ func SynchronizePublicKeys(ctx context.Context, usr *user_model.User, s *auth.So
381382 newKeys = append (newKeys , key )
382383 }
383384 }
384- if AddPublicKeysBySource (ctx , usr , s , newKeys ) {
385+ if AddPublicKeysBySource (ctx , usr , s , newKeys , verified ) {
385386 sshKeysNeedUpdate = true
386387 }
387388
0 commit comments