本站源代码
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

108 行
5.3KB

  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package setting
  5. import (
  6. "regexp"
  7. "code.gitea.io/gitea/modules/structs"
  8. )
  9. // Service settings
  10. var Service struct {
  11. DefaultOrgVisibility string
  12. DefaultOrgVisibilityMode structs.VisibleType
  13. ActiveCodeLives int
  14. ResetPwdCodeLives int
  15. RegisterEmailConfirm bool
  16. EmailDomainWhitelist []string
  17. DisableRegistration bool
  18. AllowOnlyExternalRegistration bool
  19. ShowRegistrationButton bool
  20. RequireSignInView bool
  21. EnableNotifyMail bool
  22. EnableBasicAuth bool
  23. EnableReverseProxyAuth bool
  24. EnableReverseProxyAutoRegister bool
  25. EnableReverseProxyEmail bool
  26. EnableCaptcha bool
  27. RequireExternalRegistrationCaptcha bool
  28. RequireExternalRegistrationPassword bool
  29. CaptchaType string
  30. RecaptchaSecret string
  31. RecaptchaSitekey string
  32. RecaptchaURL string
  33. DefaultKeepEmailPrivate bool
  34. DefaultAllowCreateOrganization bool
  35. EnableTimetracking bool
  36. DefaultEnableTimetracking bool
  37. DefaultEnableDependencies bool
  38. DefaultAllowOnlyContributorsToTrackTime bool
  39. NoReplyAddress string
  40. EnableUserHeatmap bool
  41. AutoWatchNewRepos bool
  42. DefaultOrgMemberVisible bool
  43. // OpenID settings
  44. EnableOpenIDSignIn bool
  45. EnableOpenIDSignUp bool
  46. OpenIDWhitelist []*regexp.Regexp
  47. OpenIDBlacklist []*regexp.Regexp
  48. }
  49. func newService() {
  50. sec := Cfg.Section("service")
  51. Service.ActiveCodeLives = sec.Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180)
  52. Service.ResetPwdCodeLives = sec.Key("RESET_PASSWD_CODE_LIVE_MINUTES").MustInt(180)
  53. Service.DisableRegistration = sec.Key("DISABLE_REGISTRATION").MustBool()
  54. Service.AllowOnlyExternalRegistration = sec.Key("ALLOW_ONLY_EXTERNAL_REGISTRATION").MustBool()
  55. Service.EmailDomainWhitelist = sec.Key("EMAIL_DOMAIN_WHITELIST").Strings(",")
  56. Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!(Service.DisableRegistration || Service.AllowOnlyExternalRegistration))
  57. Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool()
  58. Service.EnableBasicAuth = sec.Key("ENABLE_BASIC_AUTHENTICATION").MustBool(true)
  59. Service.EnableReverseProxyAuth = sec.Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool()
  60. Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool()
  61. Service.EnableReverseProxyEmail = sec.Key("ENABLE_REVERSE_PROXY_EMAIL").MustBool()
  62. Service.EnableCaptcha = sec.Key("ENABLE_CAPTCHA").MustBool(false)
  63. Service.RequireExternalRegistrationCaptcha = sec.Key("REQUIRE_EXTERNAL_REGISTRATION_CAPTCHA").MustBool(Service.EnableCaptcha)
  64. Service.RequireExternalRegistrationPassword = sec.Key("REQUIRE_EXTERNAL_REGISTRATION_PASSWORD").MustBool()
  65. Service.CaptchaType = sec.Key("CAPTCHA_TYPE").MustString(ImageCaptcha)
  66. Service.RecaptchaSecret = sec.Key("RECAPTCHA_SECRET").MustString("")
  67. Service.RecaptchaSitekey = sec.Key("RECAPTCHA_SITEKEY").MustString("")
  68. Service.RecaptchaURL = sec.Key("RECAPTCHA_URL").MustString("https://www.google.com/recaptcha/")
  69. Service.DefaultKeepEmailPrivate = sec.Key("DEFAULT_KEEP_EMAIL_PRIVATE").MustBool()
  70. Service.DefaultAllowCreateOrganization = sec.Key("DEFAULT_ALLOW_CREATE_ORGANIZATION").MustBool(true)
  71. Service.EnableTimetracking = sec.Key("ENABLE_TIMETRACKING").MustBool(true)
  72. if Service.EnableTimetracking {
  73. Service.DefaultEnableTimetracking = sec.Key("DEFAULT_ENABLE_TIMETRACKING").MustBool(true)
  74. }
  75. Service.DefaultEnableDependencies = sec.Key("DEFAULT_ENABLE_DEPENDENCIES").MustBool(true)
  76. Service.DefaultAllowOnlyContributorsToTrackTime = sec.Key("DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME").MustBool(true)
  77. Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply.example.org")
  78. Service.EnableUserHeatmap = sec.Key("ENABLE_USER_HEATMAP").MustBool(true)
  79. Service.AutoWatchNewRepos = sec.Key("AUTO_WATCH_NEW_REPOS").MustBool(true)
  80. Service.DefaultOrgVisibility = sec.Key("DEFAULT_ORG_VISIBILITY").In("public", structs.ExtractKeysFromMapString(structs.VisibilityModes))
  81. Service.DefaultOrgVisibilityMode = structs.VisibilityModes[Service.DefaultOrgVisibility]
  82. Service.DefaultOrgMemberVisible = sec.Key("DEFAULT_ORG_MEMBER_VISIBLE").MustBool()
  83. sec = Cfg.Section("openid")
  84. Service.EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(!InstallLock)
  85. Service.EnableOpenIDSignUp = sec.Key("ENABLE_OPENID_SIGNUP").MustBool(!Service.DisableRegistration && Service.EnableOpenIDSignIn)
  86. pats := sec.Key("WHITELISTED_URIS").Strings(" ")
  87. if len(pats) != 0 {
  88. Service.OpenIDWhitelist = make([]*regexp.Regexp, len(pats))
  89. for i, p := range pats {
  90. Service.OpenIDWhitelist[i] = regexp.MustCompilePOSIX(p)
  91. }
  92. }
  93. pats = sec.Key("BLACKLISTED_URIS").Strings(" ")
  94. if len(pats) != 0 {
  95. Service.OpenIDBlacklist = make([]*regexp.Regexp, len(pats))
  96. for i, p := range pats {
  97. Service.OpenIDBlacklist[i] = regexp.MustCompilePOSIX(p)
  98. }
  99. }
  100. }
上海开阖软件有限公司 沪ICP备12045867号-1