fix(ssh): fetch ssh key by fingerprint (#39423)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
TheFox0x7andwxiaoguang authored and GitHub committed 2026-09-25 06:22:04 -07:00
1 parent 6d59229331
commit 448f8c67e0
9 files changed
+60 -80

No files matched your search

+1 -1
View File
@@ -78,7 +78,7 @@ func Routes() *web.Router {
r.AfterRouting(common.AuditOrigin(audit_model.OriginSystem))
r.Get("/dummy", misc.DummyOK)
r.Post("/ssh/authorized_keys", AuthorizedPublicKeyByContent)
r.Post("/ssh/authorized_keys", AuthorizedPublicKeyForSSH)
r.Post("/ssh/{id}/update/{repoid}", UpdatePublicKeyInRepo)
r.Post("/ssh/log", bind(private.SSHLogOption{}), SSHLog)
r.Post("/hook/pre-receive/{owner}/{repo}", RepoAssignment, bind(private.HookOptions{}), HookPreReceive)
+2 -5
View File
@@ -37,12 +37,9 @@ func UpdatePublicKeyInRepo(ctx *context.PrivateContext) {
ctx.PlainText(http.StatusOK, "success")
}
// AuthorizedPublicKeyByContent searches content as prefix (without comment part)
// and returns public key found.
func AuthorizedPublicKeyByContent(ctx *context.PrivateContext) {
func AuthorizedPublicKeyForSSH(ctx *context.PrivateContext) {
content := ctx.FormString("content")
publicKey, err := asymkey_model.SearchPublicKeyByContent(ctx, content)
publicKey, err := asymkey_model.SearchPublicKeyForSSH(ctx, content)
if err != nil {
ctx.PrivateInternalErrorf("%v", err)
return