Fix user ssh key exporting and tests (#37256) (#37258)

Backport #37256 by wxiaoguang

1. Make sure OmitEmail won't panic
2. SSH principal keys are not for signing or authentication

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Giteabot
2026-04-18 03:13:41 +08:00
committed by GitHub
parent 4adee80f58
commit b191cf7e77
4 changed files with 54 additions and 28 deletions
+3
View File
@@ -655,6 +655,9 @@ func ShowSSHKeys(ctx *context.Context) {
// "authorized_keys" file format: "#" followed by comment line per key
buf.WriteString("# Gitea isn't a key server. The keys are exported as the user uploaded and might not have been fully verified.\n")
for i := range keys {
if keys[i].Type == asymkey_model.KeyTypePrincipal {
continue // SSH principal keys are not for signing or authentication
}
buf.WriteString(keys[i].OmitEmail())
buf.WriteString("\n")
}