mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Move keys to models/asymkey (#17917)
* Move keys to models/keys * Rename models/keys -> models/asymkey * change the missed package name * Fix package alias * Fix test * Fix docs * Fix test * Fix test * merge
This commit is contained in:
		@@ -22,7 +22,7 @@ import (
 | 
			
		||||
	"sync"
 | 
			
		||||
	"syscall"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/gitea/models"
 | 
			
		||||
	asymkey_model "code.gitea.io/gitea/models/asymkey"
 | 
			
		||||
	"code.gitea.io/gitea/modules/log"
 | 
			
		||||
	"code.gitea.io/gitea/modules/setting"
 | 
			
		||||
	"code.gitea.io/gitea/modules/util"
 | 
			
		||||
@@ -172,9 +172,9 @@ func publicKeyHandler(ctx ssh.Context, key ssh.PublicKey) bool {
 | 
			
		||||
		// look for the exact principal
 | 
			
		||||
	principalLoop:
 | 
			
		||||
		for _, principal := range cert.ValidPrincipals {
 | 
			
		||||
			pkey, err := models.SearchPublicKeyByContentExact(principal)
 | 
			
		||||
			pkey, err := asymkey_model.SearchPublicKeyByContentExact(principal)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				if models.IsErrKeyNotExist(err) {
 | 
			
		||||
				if asymkey_model.IsErrKeyNotExist(err) {
 | 
			
		||||
					log.Debug("Principal Rejected: %s Unknown Principal: %s", ctx.RemoteAddr(), principal)
 | 
			
		||||
					continue principalLoop
 | 
			
		||||
				}
 | 
			
		||||
@@ -232,9 +232,9 @@ func publicKeyHandler(ctx ssh.Context, key ssh.PublicKey) bool {
 | 
			
		||||
		log.Debug("Handle Public Key: %s Fingerprint: %s is not a certificate", ctx.RemoteAddr(), gossh.FingerprintSHA256(key))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	pkey, err := models.SearchPublicKeyByContent(strings.TrimSpace(string(gossh.MarshalAuthorizedKey(key))))
 | 
			
		||||
	pkey, err := asymkey_model.SearchPublicKeyByContent(strings.TrimSpace(string(gossh.MarshalAuthorizedKey(key))))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if models.IsErrKeyNotExist(err) {
 | 
			
		||||
		if asymkey_model.IsErrKeyNotExist(err) {
 | 
			
		||||
			if log.IsWarn() {
 | 
			
		||||
				log.Warn("Unknown public key: %s from %s", gossh.FingerprintSHA256(key), ctx.RemoteAddr())
 | 
			
		||||
				log.Warn("Failed authentication attempt from %s", ctx.RemoteAddr())
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user