diff --git a/modules/templates/helper.go b/modules/templates/helper.go index fc07b49c71925..7c14bd49ed240 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -239,6 +239,9 @@ func NewFuncMap() []template.FuncMap { "DisableImportLocal": func() bool { return !setting.ImportLocalPaths }, + "DisableSSH": func() bool { + return setting.SSH.Disabled + }, "Dict": func(values ...interface{}) (map[string]interface{}, error) { if len(values)%2 != 0 { return nil, errors.New("invalid dict call") diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index d8398f6d9fc5b..1a84efa864483 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -518,6 +518,7 @@ password = Password security = Security avatar = Avatar ssh_gpg_keys = SSH / GPG Keys +gpg_keys = GPG Keys social = Social Accounts applications = Applications orgs = Manage Organizations diff --git a/services/cron/tasks_extended.go b/services/cron/tasks_extended.go index ded819a71e917..0f53d0181f36e 100644 --- a/services/cron/tasks_extended.go +++ b/services/cron/tasks_extended.go @@ -158,8 +158,12 @@ func initExtendedTasks() { registerDeleteInactiveUsers() registerDeleteRepositoryArchives() registerGarbageCollectRepositories() - registerRewriteAllPublicKeys() - registerRewriteAllPrincipalKeys() + if !setting.SSH.Disabled && !setting.SSH.StartBuiltinServer && setting.SSH.CreateAuthorizedKeysFile { + registerRewriteAllPublicKeys() + } + if !setting.SSH.Disabled && !setting.SSH.StartBuiltinServer && setting.SSH.CreateAuthorizedPrincipalsFile { + registerRewriteAllPrincipalKeys() + } registerRepositoryUpdateHook() registerReinitMissingRepositories() registerDeleteMissingRepositories() diff --git a/templates/admin/dashboard.tmpl b/templates/admin/dashboard.tmpl index 35f45bd3529c4..6fffff3176ef1 100644 --- a/templates/admin/dashboard.tmpl +++ b/templates/admin/dashboard.tmpl @@ -40,12 +40,14 @@ {{.i18n.Tr "admin.dashboard.git_gc_repos"}} - {{if and (not .SSH.Disabled) (not .SSH.StartBuiltinServer)}} + {{if and (not .SSH.Disabled) (not .SSH.StartBuiltinServer) (.SSH.CreateAuthorizedKeysFile) }} {{.i18n.Tr "admin.dashboard.resync_all_sshkeys"}}
{{.i18n.Tr "admin.dashboard.resync_all_sshkeys.desc"}} + {{end}} + {{if and (not .SSH.Disabled) (not .SSH.StartBuiltinServer) (.SSH.CreateAuthorizedPrincipalsFile) }} {{.i18n.Tr "admin.dashboard.resync_all_sshprincipals"}}
{{.i18n.Tr "admin.dashboard.resync_all_sshprincipals.desc"}} diff --git a/templates/repo/settings/deploy_keys.tmpl b/templates/repo/settings/deploy_keys.tmpl index 019a62b5f12f6..2f88bfaca3979 100644 --- a/templates/repo/settings/deploy_keys.tmpl +++ b/templates/repo/settings/deploy_keys.tmpl @@ -7,11 +7,7 @@

{{.i18n.Tr "repo.settings.deploy_keys"}}
- {{if not .DisableSSH}}
{{.i18n.Tr "repo.settings.add_deploy_key"}}
- {{else}} -
{{.i18n.Tr "settings.ssh_disabled"}}
- {{end}}

diff --git a/templates/repo/settings/nav.tmpl b/templates/repo/settings/nav.tmpl index 31672cb5ead0f..940fb7dc039d0 100644 --- a/templates/repo/settings/nav.tmpl +++ b/templates/repo/settings/nav.tmpl @@ -12,7 +12,9 @@ {{if or .SignedUser.AllowGitHook .SignedUser.IsAdmin}}
  • {{.i18n.Tr "repo.settings.githooks"}}
  • {{end}} + {{if not DisableSSH}}
  • {{.i18n.Tr "repo.settings.deploy_keys"}}
  • + {{end}}
    diff --git a/templates/repo/settings/navbar.tmpl b/templates/repo/settings/navbar.tmpl index d8cdf218719bd..cef0f626d0879 100644 --- a/templates/repo/settings/navbar.tmpl +++ b/templates/repo/settings/navbar.tmpl @@ -24,9 +24,11 @@ {{.i18n.Tr "repo.settings.githooks"}} {{end}} + {{if not DisableSSH}} {{.i18n.Tr "repo.settings.deploy_keys"}} + {{end}} {{if .LFSStartServer}} {{.i18n.Tr "repo.settings.lfs"}} diff --git a/templates/user/settings/keys_principal.tmpl b/templates/user/settings/keys_principal.tmpl index 9d8ebab609b93..b0149db14a0b8 100644 --- a/templates/user/settings/keys_principal.tmpl +++ b/templates/user/settings/keys_principal.tmpl @@ -1,12 +1,8 @@ -{{if .AllowPrincipals}} +{{if and .AllowPrincipals (not DisableSSH)}}

    {{.i18n.Tr "settings.manage_ssh_principals"}}
    - {{if not .DisableSSH}}
    {{.i18n.Tr "settings.add_new_principal"}}
    - {{else}} -
    {{.i18n.Tr "settings.ssh_disabled"}}
    - {{end}}

    diff --git a/templates/user/settings/keys_ssh.tmpl b/templates/user/settings/keys_ssh.tmpl index 85f11c6e4ad73..169c199fc4ace 100644 --- a/templates/user/settings/keys_ssh.tmpl +++ b/templates/user/settings/keys_ssh.tmpl @@ -1,13 +1,10 @@ +{{if not DisableSSH}}

    {{.i18n.Tr "settings.manage_ssh_keys"}}
    - {{if not .DisableSSH }} -
    - {{.i18n.Tr "settings.add_key"}} -
    - {{else}} -
    {{.i18n.Tr "settings.ssh_disabled"}}
    - {{end}} +
    + {{.i18n.Tr "settings.add_key"}} +

    @@ -109,3 +106,4 @@
    {{template "base/delete_modal_actions" .}}
    +{{end}} diff --git a/templates/user/settings/navbar.tmpl b/templates/user/settings/navbar.tmpl index 3477a5949b849..ea0ed891eb008 100644 --- a/templates/user/settings/navbar.tmpl +++ b/templates/user/settings/navbar.tmpl @@ -16,7 +16,7 @@ {{.i18n.Tr "settings.applications"}}
    - {{.i18n.Tr "settings.ssh_gpg_keys"}} + {{if DisableSSH}}{{.i18n.Tr "settings.gpg_keys"}}{{else}}{{.i18n.Tr "settings.ssh_gpg_keys"}}{{end}} {{.i18n.Tr "settings.organization"}}