From ee0fbddf5be446cbe4f86b3d878f6f98e842a3bd Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Sun, 9 Apr 2023 21:56:12 +0300 Subject: [PATCH 1/3] Allow adding SSH keys even if SSH server is disabled This is useful in case you want to use them for signature verification. A notice is added to avoid confusion. --- models/asymkey/ssh_key_parse.go | 5 ----- options/locale/locale_en-US.ini | 1 + templates/user/settings/keys_ssh.tmpl | 15 ++++++++------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/models/asymkey/ssh_key_parse.go b/models/asymkey/ssh_key_parse.go index 8693c87e76b2..7e61e61dae55 100644 --- a/models/asymkey/ssh_key_parse.go +++ b/models/asymkey/ssh_key_parse.go @@ -16,7 +16,6 @@ import ( "strconv" "strings" - "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" "code.gitea.io/gitea/modules/setting" @@ -158,10 +157,6 @@ func parseKeyString(content string) (string, error) { // CheckPublicKeyString checks if the given public key string is recognized by SSH. // It returns the actual public key line on success. func CheckPublicKeyString(content string) (_ string, err error) { - if setting.SSH.Disabled { - return "", db.ErrSSHDisabled{} - } - content, err = parseKeyString(content) if err != nil { return "", err diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index eb1ffebc3771..186d59cadb8b 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -739,6 +739,7 @@ principal_state_desc = This principal has been used in the last 7 days show_openid = Show on profile hide_openid = Hide from profile ssh_disabled = SSH Disabled +ssh_signonly = Notice: SSH is disabled, these keys will only be used for verifying commit signatures ssh_externally_managed = This SSH key is externally managed for this user manage_social = Manage Associated Social Accounts social_desc = These social accounts are linked to your Gitea account. Make sure you recognize all of them as they can be used to sign in to your Gitea account. diff --git a/templates/user/settings/keys_ssh.tmpl b/templates/user/settings/keys_ssh.tmpl index 5d518f3bb08e..160dedc93c5a 100644 --- a/templates/user/settings/keys_ssh.tmpl +++ b/templates/user/settings/keys_ssh.tmpl @@ -1,13 +1,9 @@

{{.locale.Tr "settings.manage_ssh_keys"}}
- {{if not .DisableSSH}} - - {{else}} - - {{end}} +

@@ -35,6 +31,11 @@
{{.locale.Tr "settings.ssh_desc"}}
+ {{if .DisableSSH}} +
+ {{.locale.Tr "settings.ssh_signonly"}} +
+ {{end}} {{range $index, $key := .Keys}}
From 720aba83132b6cd98520f5a5b5d72cefee3ee4bb Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Sun, 9 Apr 2023 22:42:27 +0300 Subject: [PATCH 2/3] Update options/locale/locale_en-US.ini Co-authored-by: silverwind --- options/locale/locale_en-US.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 186d59cadb8b..09dbc3fbca4f 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -739,7 +739,7 @@ principal_state_desc = This principal has been used in the last 7 days show_openid = Show on profile hide_openid = Hide from profile ssh_disabled = SSH Disabled -ssh_signonly = Notice: SSH is disabled, these keys will only be used for verifying commit signatures +ssh_signonly = SSH is disabled, these keys will only be used for verifying commit signatures ssh_externally_managed = This SSH key is externally managed for this user manage_social = Manage Associated Social Accounts social_desc = These social accounts are linked to your Gitea account. Make sure you recognize all of them as they can be used to sign in to your Gitea account. From dec3ede46274e3b4ecede99cf3b8bd57ab3c0480 Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Mon, 10 Apr 2023 13:08:12 +0300 Subject: [PATCH 3/3] Update options/locale/locale_en-US.ini Co-authored-by: silverwind --- options/locale/locale_en-US.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 09dbc3fbca4f..d10c585ec99b 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -739,7 +739,7 @@ principal_state_desc = This principal has been used in the last 7 days show_openid = Show on profile hide_openid = Hide from profile ssh_disabled = SSH Disabled -ssh_signonly = SSH is disabled, these keys will only be used for verifying commit signatures +ssh_signonly = SSH is currently disabled so these keys are only used for commit signature verification. ssh_externally_managed = This SSH key is externally managed for this user manage_social = Manage Associated Social Accounts social_desc = These social accounts are linked to your Gitea account. Make sure you recognize all of them as they can be used to sign in to your Gitea account.