diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index dc273ced80054..09a4e7b5080d1 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -541,6 +541,8 @@ IMPORT_LOCAL_PATHS = false ; It also enables them to access other resources available to the user on the operating system that is running the Gitea instance and perform arbitrary actions in the name of the Gitea OS user. ; WARNING: This maybe harmful to you website or your operating system. DISABLE_GIT_HOOKS = true +; Set to false to disable 2FA feature. +DISABLE_2FA = false ; Set to false to allow pushes to gitea repositories despite having an incomplete environment - NOT RECOMMENDED ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET = true ;Comma separated list of character classes required to pass minimum complexity. diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md index 9e61a25f33603..cfaf4e8241bca 100644 --- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md +++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md @@ -400,6 +400,7 @@ relation to port exhaustion. It also enables them to access other resources available to the user on the operating system that is running the Gitea instance and perform arbitrary actions in the name of the Gitea OS user. This maybe harmful to you website or your operating system. +- `DISABLE_2FA`: **false**: Set to `true` to disable 2FA feature. - `ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET`: **true**: Set to `false` to allow local users to push to gitea-repositories without setting up the Gitea environment. This is not recommended and if you want local users to push to gitea repositories you should set the environment appropriately. - `IMPORT_LOCAL_PATHS`: **false**: Set to `false` to prevent all users (including admin) from importing local path on server. - `INTERNAL_TOKEN`: **\**: Secret used to validate communication within Gitea binary. diff --git a/modules/cron/tasks_extended.go b/modules/cron/tasks_extended.go index f0742eb471f36..cf0c9f3d357f1 100644 --- a/modules/cron/tasks_extended.go +++ b/modules/cron/tasks_extended.go @@ -121,9 +121,15 @@ func initExtendedTasks() { registerDeleteInactiveUsers() registerDeleteRepositoryArchives() registerGarbageCollectRepositories() - registerRewriteAllPublicKeys() - registerRewriteAllPrincipalKeys() - registerRepositoryUpdateHook() + if !setting.SSH.Disabled && !setting.SSH.StartBuiltinServer && setting.SSH.CreateAuthorizedKeysFile { + registerRewriteAllPublicKeys() + } + if !setting.SSH.Disabled && !setting.SSH.StartBuiltinServer && setting.SSH.CreateAuthorizedPrincipalsFile { + registerRewriteAllPrincipalKeys() + } + if !setting.DisableGitHooks { + registerRepositoryUpdateHook() + } registerReinitMissingRepositories() registerDeleteMissingRepositories() registerRemoveRandomAvatars() diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 7ae8bb352de10..2663a2ab33da1 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -152,6 +152,7 @@ var ( MinPasswordLength int ImportLocalPaths bool DisableGitHooks bool + Disable2FA bool OnlyAllowPushIfGiteaEnvironmentSet bool PasswordComplexity []string PasswordHashAlgo string @@ -770,6 +771,7 @@ func NewContext() { MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt(6) ImportLocalPaths = sec.Key("IMPORT_LOCAL_PATHS").MustBool(false) DisableGitHooks = sec.Key("DISABLE_GIT_HOOKS").MustBool(true) + Disable2FA = sec.Key("DISABLE_2FA").MustBool(false) OnlyAllowPushIfGiteaEnvironmentSet = sec.Key("ONLY_ALLOW_PUSH_IF_GITEA_ENVIRONMENT_SET").MustBool(true) PasswordHashAlgo = sec.Key("PASSWORD_HASH_ALGO").MustString("argon2") CSRFCookieHTTPOnly = sec.Key("CSRF_COOKIE_HTTP_ONLY").MustBool(true) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 63be27d98735a..7040f718ee174 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -228,6 +228,15 @@ func NewFuncMap() []template.FuncMap { "DisableImportLocal": func() bool { return !setting.ImportLocalPaths }, + "DisableSSH": func() bool { + return setting.SSH.Disabled + }, + "DisableOAuth2": func() bool { + return !setting.OAuth2.Enable + }, + "Disable2FA": func() bool { + return setting.Disable2FA + }, "TrN": TrN, "Dict": func(values ...interface{}) (map[string]interface{}, error) { if len(values)%2 != 0 { diff --git a/options/locale/locale_bg-BG.ini b/options/locale/locale_bg-BG.ini index 8fff3f129fdfc..0d28ea45313c0 100644 --- a/options/locale/locale_bg-BG.ini +++ b/options/locale/locale_bg-BG.ini @@ -358,7 +358,6 @@ account=Профил password=Парола security=Сигурност avatar=Аватар -ssh_gpg_keys=SSH / GPG ключове social=Социални профили applications=Приложения orgs=Управление на организации diff --git a/options/locale/locale_cs-CZ.ini b/options/locale/locale_cs-CZ.ini index 08a9fc475d54d..40c50ce677ee1 100644 --- a/options/locale/locale_cs-CZ.ini +++ b/options/locale/locale_cs-CZ.ini @@ -416,7 +416,6 @@ account=Účet password=Heslo security=Zabezpečení avatar=Avatar -ssh_gpg_keys=SSH / GPG klíče social=Účty sociálních sítí applications=Aplikace orgs=Spravovat organizace diff --git a/options/locale/locale_de-DE.ini b/options/locale/locale_de-DE.ini index fde5b5c281fb9..65be80a2c980d 100644 --- a/options/locale/locale_de-DE.ini +++ b/options/locale/locale_de-DE.ini @@ -416,7 +416,6 @@ account=Account password=Passwort security=Sicherheit avatar=Profilbild -ssh_gpg_keys=SSH- / GPG-Schlüssel social=Soziale Konten applications=Anwendungen orgs=Organisationen verwalten diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 16d3874e1bec8..1e7b4f785c35c 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -418,7 +418,7 @@ account = Account password = Password security = Security avatar = Avatar -ssh_gpg_keys = SSH / GPG Keys +keys = Keys social = Social Accounts applications = Applications orgs = Manage Organizations diff --git a/options/locale/locale_es-ES.ini b/options/locale/locale_es-ES.ini index fa579ab3a9a15..5031b29cb1e2e 100644 --- a/options/locale/locale_es-ES.ini +++ b/options/locale/locale_es-ES.ini @@ -417,7 +417,6 @@ account=Cuenta password=Contraseña security=Seguridad avatar=Avatar -ssh_gpg_keys=SSH / claves GPG social=Redes Sociales applications=Aplicaciones orgs=Administrar organizaciones diff --git a/options/locale/locale_fa-IR.ini b/options/locale/locale_fa-IR.ini index 0f1508fdff6ad..1a2de0d337a5c 100644 --- a/options/locale/locale_fa-IR.ini +++ b/options/locale/locale_fa-IR.ini @@ -407,7 +407,6 @@ account=حساب کاربری password=گذرواژه security=امنیت avatar=آواتار -ssh_gpg_keys=کلید‌های SSH / GPG social=حساب های اجتماعی applications=برنامه‌ها orgs=مدیریت سازمان‌ها diff --git a/options/locale/locale_fi-FI.ini b/options/locale/locale_fi-FI.ini index d05059ff4b215..efb3403fe7148 100644 --- a/options/locale/locale_fi-FI.ini +++ b/options/locale/locale_fi-FI.ini @@ -348,7 +348,6 @@ account=Tili password=Salasana security=Turvallisuus avatar=Profiilikuva -ssh_gpg_keys=SSH / GPG-avaimet social=Sosiaaliset tilit applications=Sovellukset orgs=Hallitse organisaatioita diff --git a/options/locale/locale_fr-FR.ini b/options/locale/locale_fr-FR.ini index 0c10779ae73de..22ca83dc01db7 100644 --- a/options/locale/locale_fr-FR.ini +++ b/options/locale/locale_fr-FR.ini @@ -394,7 +394,6 @@ account=Compte password=Mot de passe security=Sécurité avatar=Avatar -ssh_gpg_keys=Clés SSH / GPG social=Réseaux Sociaux applications=Applications orgs=Gérer les organisations diff --git a/options/locale/locale_hu-HU.ini b/options/locale/locale_hu-HU.ini index e13f69a706800..6977a271d1f35 100644 --- a/options/locale/locale_hu-HU.ini +++ b/options/locale/locale_hu-HU.ini @@ -380,7 +380,6 @@ account=Fiók password=Jelszó security=Biztonság avatar=Profilkép -ssh_gpg_keys=SSH / GPG kulcsok social=Közösségi fiókok applications=Alkalmazások orgs=Szervezetek kezelése diff --git a/options/locale/locale_id-ID.ini b/options/locale/locale_id-ID.ini index 249fb61c77523..59d7225f2a5a9 100644 --- a/options/locale/locale_id-ID.ini +++ b/options/locale/locale_id-ID.ini @@ -384,7 +384,6 @@ account=Akun password=Kata Sandi security=Keamanan avatar=Avatar -ssh_gpg_keys=Kunci SSH / GPG social=Akun Sosial applications=Aplikasi orgs=Kelola organisasi diff --git a/options/locale/locale_it-IT.ini b/options/locale/locale_it-IT.ini index 622e58b5c0869..a3a3ce77316d9 100644 --- a/options/locale/locale_it-IT.ini +++ b/options/locale/locale_it-IT.ini @@ -416,7 +416,6 @@ account=Account password=Password security=Sicurezza avatar=Avatar -ssh_gpg_keys=Chiavi SSH / GPG social=Account Sociali applications=Applicazioni orgs=Gestisci le organizzazioni diff --git a/options/locale/locale_ja-JP.ini b/options/locale/locale_ja-JP.ini index 49ea9ee32000f..57b4ecbcf9832 100644 --- a/options/locale/locale_ja-JP.ini +++ b/options/locale/locale_ja-JP.ini @@ -417,7 +417,6 @@ account=アカウント password=パスワード security=セキュリティ avatar=アバター -ssh_gpg_keys=SSH / GPGキー social=ソーシャルアカウント applications=アプリケーション orgs=組織の管理 diff --git a/options/locale/locale_ko-KR.ini b/options/locale/locale_ko-KR.ini index 01b0dba7ebdda..260f5276e8b19 100644 --- a/options/locale/locale_ko-KR.ini +++ b/options/locale/locale_ko-KR.ini @@ -365,7 +365,6 @@ account=계정 password=비밀번호 security=보안 avatar=아바타 -ssh_gpg_keys=SSH / GPG 키 social=소셜 계정 applications=어플리케이션 orgs=조직 관리 diff --git a/options/locale/locale_lv-LV.ini b/options/locale/locale_lv-LV.ini index d1f5b53a283b7..ec984f4f33bee 100644 --- a/options/locale/locale_lv-LV.ini +++ b/options/locale/locale_lv-LV.ini @@ -417,7 +417,6 @@ account=Konts password=Parole security=Drošība avatar=Profila attēls -ssh_gpg_keys=SSH / GPG atslēgas social=Sociālie konti applications=Lietotnes orgs=Pārvaldīt organizācijas diff --git a/options/locale/locale_ml-IN.ini b/options/locale/locale_ml-IN.ini index f361e71a95704..c57910e02848e 100644 --- a/options/locale/locale_ml-IN.ini +++ b/options/locale/locale_ml-IN.ini @@ -356,7 +356,6 @@ account=അക്കൗണ്ട് password=രഹസ്യവാക്കു് security=സുരക്ഷ avatar=അവതാര്‍ -ssh_gpg_keys=SSH / GPG കീകള്‍ social=സോഷ്യൽ അക്കൗണ്ടുകൾ applications=അപ്ലിക്കേഷനുകൾ orgs=സംഘടനകളെ നിയന്ത്രിക്കുക diff --git a/options/locale/locale_nl-NL.ini b/options/locale/locale_nl-NL.ini index d072b9656c6dd..35a1b62f9b930 100644 --- a/options/locale/locale_nl-NL.ini +++ b/options/locale/locale_nl-NL.ini @@ -417,7 +417,6 @@ account=Account password=Wachtwoord security=Beveiliging avatar=Profielfoto -ssh_gpg_keys=SSH / GPG sleutels social=Sociale netwerk-accounts applications=Applicaties orgs=Beheer organisaties diff --git a/options/locale/locale_pl-PL.ini b/options/locale/locale_pl-PL.ini index c12916dfb547a..6f5948ce21b40 100644 --- a/options/locale/locale_pl-PL.ini +++ b/options/locale/locale_pl-PL.ini @@ -407,7 +407,7 @@ account=Konto password=Hasło security=Bezpieczeństwo avatar=Awatar -ssh_gpg_keys=Klucze SSH / GPG +keys=Klucze social=Konta społecznościowe applications=Aplikacje orgs=Zarządzaj organizacjami diff --git a/options/locale/locale_pt-BR.ini b/options/locale/locale_pt-BR.ini index 680e7f591bfa9..01c1b06667e3e 100644 --- a/options/locale/locale_pt-BR.ini +++ b/options/locale/locale_pt-BR.ini @@ -396,7 +396,6 @@ account=Conta password=Senha security=Segurança avatar=Avatar -ssh_gpg_keys=Chaves SSH / GPG social=Contas sociais applications=Aplicativos orgs=Gerenciar organizações diff --git a/options/locale/locale_pt-PT.ini b/options/locale/locale_pt-PT.ini index 722a873a0c286..ae24efaa3f7ac 100644 --- a/options/locale/locale_pt-PT.ini +++ b/options/locale/locale_pt-PT.ini @@ -417,7 +417,6 @@ account=Conta password=Senha security=Segurança avatar=Avatar -ssh_gpg_keys=Chaves SSH / GPG social=Contas sociais applications=Aplicações orgs=Gerir organizações diff --git a/options/locale/locale_ru-RU.ini b/options/locale/locale_ru-RU.ini index 620bcfcd322c8..feb3865b3d2c2 100644 --- a/options/locale/locale_ru-RU.ini +++ b/options/locale/locale_ru-RU.ini @@ -416,7 +416,6 @@ account=Аккаунт password=Пароль security=Безопасность avatar=Аватар -ssh_gpg_keys=SSH / GPG ключи social=Учетные записи в соцсетях applications=Приложения orgs=Управление организациями diff --git a/options/locale/locale_sv-SE.ini b/options/locale/locale_sv-SE.ini index 82d26db05fab2..a3764d56e1aa0 100644 --- a/options/locale/locale_sv-SE.ini +++ b/options/locale/locale_sv-SE.ini @@ -416,7 +416,6 @@ account=Konto password=Lösenord security=Säkerhet avatar=Visningsbild -ssh_gpg_keys=SSH / GPG-nycklar social=Sociala konton applications=Applikationer orgs=Hantera Organisationer diff --git a/options/locale/locale_tr-TR.ini b/options/locale/locale_tr-TR.ini index 7bc2744c7a774..ad1190fbb2bdf 100644 --- a/options/locale/locale_tr-TR.ini +++ b/options/locale/locale_tr-TR.ini @@ -417,7 +417,6 @@ account=Hesap password=Parola security=Güvenlik avatar=Avatar -ssh_gpg_keys=SSH / GPG Anahtarları social=Sosyal Medya Hesapları applications=Uygulamalar orgs=Organizasyonları Yönet diff --git a/options/locale/locale_uk-UA.ini b/options/locale/locale_uk-UA.ini index 75a08ed59f7c1..71d56c400352a 100644 --- a/options/locale/locale_uk-UA.ini +++ b/options/locale/locale_uk-UA.ini @@ -407,7 +407,6 @@ account=Обліковий запис password=Пароль security=Безпека avatar=Аватар -ssh_gpg_keys=SSH / GPG ключі social=Соціальні облікові записи applications=Додатки orgs=Керування організаціями diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 3944904c7e43d..10ed5e54af799 100644 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -417,7 +417,6 @@ account=账号 password=修改密码 security=安全 avatar=头像设置 -ssh_gpg_keys=SSH / GPG 密钥 social=社交帐号绑定 applications=应用 orgs=管理组织 diff --git a/options/locale/locale_zh-HK.ini b/options/locale/locale_zh-HK.ini index 51c376961d804..4480237a227cb 100644 --- a/options/locale/locale_zh-HK.ini +++ b/options/locale/locale_zh-HK.ini @@ -167,7 +167,6 @@ form.name_reserved=這個使用者名稱已被系統保留,請改用其他名 profile=個人訊息 password=修改密碼 avatar=頭像 -ssh_gpg_keys=SSH / GPG 金鑰 social=社交帳號綁定 delete=刪除帳戶 twofa=兩步驟驗證 diff --git a/options/locale/locale_zh-TW.ini b/options/locale/locale_zh-TW.ini index 5526105107733..fc9f0b4dc865b 100644 --- a/options/locale/locale_zh-TW.ini +++ b/options/locale/locale_zh-TW.ini @@ -407,7 +407,6 @@ account=帳戶 password=修改密碼 security=安全性 avatar=大頭貼 -ssh_gpg_keys=SSH / GPG 金鑰 social=社群帳戶 applications=應用程式 orgs=管理組織 diff --git a/routers/routes/routes.go b/routers/routes/routes.go index a09e53efc1f89..82a16c51dbc0f 100644 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -370,9 +370,18 @@ func RegisterRoutes(m *macaron.Macaron) { m.Get("/:provider", user.SignInOAuth) m.Get("/:provider/callback", user.SignInOAuthCallback) }) - m.Get("/link_account", user.LinkAccount) - m.Post("/link_account_signin", bindIgnErr(auth.SignInForm{}), user.LinkAccountPostSignIn) - m.Post("/link_account_signup", bindIgnErr(auth.RegisterForm{}), user.LinkAccountPostRegister) + m.Group("/link_account", func() { + m.Get("", user.LinkAccount) + }, openIDSignInEnabled) + + m.Group("/link_account_signin", func() { + m.Post("", bindIgnErr(auth.SignInForm{}), user.LinkAccountPostSignIn) + }, openIDSignInEnabled) + + m.Group("/link_account_signup", func() { + m.Post("", bindIgnErr(auth.RegisterForm{}), user.LinkAccountPostRegister) + }, openIDSignUpEnabled) + m.Group("/two_factor", func() { m.Get("", user.TwoFactor) m.Post("", bindIgnErr(auth.TwoFactorAuthForm{}), user.TwoFactorPost) @@ -429,7 +438,10 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/delete", userSetting.DeleteOpenID) m.Post("/toggle_visibility", userSetting.ToggleOpenIDVisibility) }, openIDSignInEnabled) - m.Post("/account_link", userSetting.DeleteAccountLink) + + m.Group("/account_link", func() { + m.Post("", userSetting.DeleteAccountLink) + }, openIDSignInEnabled) }) m.Group("/applications/oauth2", func() { m.Get("/:id", userSetting.OAuth2ApplicationShow) diff --git a/routers/user/setting/applications.go b/routers/user/setting/applications.go index 04f9d9f7f9b92..f914604a5f8ff 100644 --- a/routers/user/setting/applications.go +++ b/routers/user/setting/applications.go @@ -6,6 +6,8 @@ package setting import ( + "fmt" + "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth" "code.gitea.io/gitea/modules/base" @@ -39,6 +41,11 @@ func ApplicationsPost(ctx *context.Context, form auth.NewAccessTokenForm) { return } + if !setting.API.EnableSwagger { + ctx.ServerError("AccessToken", fmt.Errorf("cannot modify access tokens; swagger disabled")) + return + } + t := &models.AccessToken{ UID: ctx.User.ID, Name: form.Name, @@ -68,6 +75,11 @@ func ApplicationsPost(ctx *context.Context, form auth.NewAccessTokenForm) { // DeleteApplication response for delete user access token func DeleteApplication(ctx *context.Context) { + if !setting.API.EnableSwagger { + ctx.ServerError("DeleteAccessToken", fmt.Errorf("cannot delete access token; swagger disabled")) + return + } + if err := models.DeleteAccessTokenByID(ctx.QueryInt64("id"), ctx.User.ID); err != nil { ctx.Flash.Error("DeleteAccessTokenByID: " + err.Error()) } else { @@ -80,14 +92,17 @@ func DeleteApplication(ctx *context.Context) { } func loadApplicationsData(ctx *context.Context) { - tokens, err := models.ListAccessTokens(models.ListAccessTokensOptions{UserID: ctx.User.ID}) - if err != nil { - ctx.ServerError("ListAccessTokens", err) - return + if setting.API.EnableSwagger { + tokens, err := models.ListAccessTokens(models.ListAccessTokensOptions{UserID: ctx.User.ID}) + if err != nil { + ctx.ServerError("ListAccessTokens", err) + return + } + ctx.Data["Tokens"] = tokens } - ctx.Data["Tokens"] = tokens ctx.Data["EnableOAuth2"] = setting.OAuth2.Enable if setting.OAuth2.Enable { + var err error ctx.Data["Applications"], err = models.GetOAuth2ApplicationsByUserID(ctx.User.ID) if err != nil { ctx.ServerError("GetOAuth2ApplicationsByUserID", err) diff --git a/templates/admin/dashboard.tmpl b/templates/admin/dashboard.tmpl index 911cdb9fef3ab..249f5f31b3b11 100644 --- a/templates/admin/dashboard.tmpl +++ b/templates/admin/dashboard.tmpl @@ -35,22 +35,26 @@ {{.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"}} + {{end}} + {{if not DisableGitHooks}} {{.i18n.Tr "admin.dashboard.resync_all_hooks"}} + {{end}} {{.i18n.Tr "admin.dashboard.reinit_missing_repos"}} diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl index 95323a97b215d..b8a71c6803d52 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -89,7 +89,7 @@ -
+
diff --git a/templates/admin/user/list.tmpl b/templates/admin/user/list.tmpl index d6dd7d5c03969..d6fa89e3fa32b 100644 --- a/templates/admin/user/list.tmpl +++ b/templates/admin/user/list.tmpl @@ -25,7 +25,9 @@ {{.i18n.Tr "admin.users.activated"}} {{.i18n.Tr "admin.users.admin"}} {{.i18n.Tr "admin.users.restricted"}} + {{if not Disable2FA}} {{.i18n.Tr "admin.users.2fa"}} + {{end}} {{.i18n.Tr "admin.users.repos"}} {{.i18n.Tr "admin.users.created"}} @@ -44,7 +46,9 @@ + {{if not Disable2FA}} + {{end}} {{.NumRepos}} {{.CreatedUnix.FormatShort}} {{if .LastLoginUnix}} diff --git a/templates/org/member/members.tmpl b/templates/org/member/members.tmpl index f33f9be927aa3..944ba2163a584 100644 --- a/templates/org/member/members.tmpl +++ b/templates/org/member/members.tmpl @@ -37,6 +37,7 @@ {{if index $.MembersIsUserOrgOwner .ID}}{{svg "octicon-shield-lock"}} {{$.i18n.Tr "org.members.owner"}}{{else}}{{$.i18n.Tr "org.members.member"}}{{end}}
+ {{if not Disable2FA}}
{{$.i18n.Tr "admin.users.2fa"}} @@ -51,6 +52,7 @@
+ {{end}}
{{if eq $.SignedUser.ID .ID}} diff --git a/templates/repo/settings/deploy_keys.tmpl b/templates/repo/settings/deploy_keys.tmpl index 15d861d74ec75..d79346a444fa6 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 5cc77e1dc91ca..a84c921b9c687 100644 --- a/templates/repo/settings/nav.tmpl +++ b/templates/repo/settings/nav.tmpl @@ -9,7 +9,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 abd6e285dc3e3..32625bc4fd222 100644 --- a/templates/repo/settings/navbar.tmpl +++ b/templates/repo/settings/navbar.tmpl @@ -18,9 +18,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/applications.tmpl b/templates/user/settings/applications.tmpl index b2751ae13b7f9..75cef98a505ae 100644 --- a/templates/user/settings/applications.tmpl +++ b/templates/user/settings/applications.tmpl @@ -3,6 +3,7 @@ {{template "user/settings/navbar" .}}
    {{template "base/alert" .}} + {{if .EnableSwagger}}

    {{.i18n.Tr "settings.manage_access_token"}}

    @@ -45,6 +46,7 @@
    + {{end}} {{if .EnableOAuth2}} {{template "user/settings/grants_oauth2" .}} diff --git a/templates/user/settings/keys_principal.tmpl b/templates/user/settings/keys_principal.tmpl index c163263ea9bf5..7a6e91bfce3db 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 3d41f335953e6..fbd23cbbf978e 100644 --- a/templates/user/settings/keys_ssh.tmpl +++ b/templates/user/settings/keys_ssh.tmpl @@ -1,11 +1,8 @@ +{{if not DisableSSH}}

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

    @@ -71,3 +68,4 @@
    {{template "base/delete_modal_actions" .}}
    +{{end}} diff --git a/templates/user/settings/navbar.tmpl b/templates/user/settings/navbar.tmpl index 18bd9a4f8d6e8..acb02a9ddbb6b 100644 --- a/templates/user/settings/navbar.tmpl +++ b/templates/user/settings/navbar.tmpl @@ -5,14 +5,18 @@
    {{.i18n.Tr "settings.account"}} + {{if or (not Disable2FA) .EnableOpenIDSignIn}} {{.i18n.Tr "settings.security"}} - - {{.i18n.Tr "settings.applications"}} - + {{end}} + {{if or .EnableSwagger (not DisableOAuth2)}} + + {{.i18n.Tr "settings.applications"}} + + {{end}} - {{.i18n.Tr "settings.ssh_gpg_keys"}} + {{.i18n.Tr "settings.keys"}} {{.i18n.Tr "settings.organization"}} diff --git a/templates/user/settings/security.tmpl b/templates/user/settings/security.tmpl index c2c99c79794d5..c74f016ec2be2 100644 --- a/templates/user/settings/security.tmpl +++ b/templates/user/settings/security.tmpl @@ -3,10 +3,12 @@ {{template "user/settings/navbar" .}}
    {{template "base/alert" .}} + {{if not Disable2FA}} {{template "user/settings/security_twofa" .}} {{template "user/settings/security_u2f" .}} - {{template "user/settings/security_accountlinks" .}} + {{end}} {{if .EnableOpenIDSignIn}} + {{template "user/settings/security_accountlinks" .}} {{template "user/settings/security_openid" .}} {{end}}