aboutsummaryrefslogtreecommitdiffstats
path: root/modules/ssh/ssh.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-12-10 16:14:24 +0800
committerGitHub <noreply@github.com>2021-12-10 16:14:24 +0800
commit3ca5dc7e32b372d14ff80d96f14b8f6a805862f1 (patch)
tree50d193ed0dacf2888d57b193a9b0d36065aff205 /modules/ssh/ssh.go
parent0a9fcf63a49799ad3b0f146c54879161bac61e10 (diff)
downloadgitea-3ca5dc7e32b372d14ff80d96f14b8f6a805862f1.tar.gz
gitea-3ca5dc7e32b372d14ff80d96f14b8f6a805862f1.zip
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
Diffstat (limited to 'modules/ssh/ssh.go')
-rw-r--r--modules/ssh/ssh.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go
index 5f19dd4a5c..a3756fd2af 100644
--- a/modules/ssh/ssh.go
+++ b/modules/ssh/ssh.go
@@ -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())