aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorSandro Santilli <strk@kbt.io>2017-03-29 12:57:43 +0200
committerBo-Yi Wu <appleboy.tw@gmail.com>2017-03-29 18:57:43 +0800
commit129b0d6a4b408555c579e7ccb2fb15d3d8fcef29 (patch)
tree88912e81e84c11f1ee7993b9409bf50a23aa7aef /modules
parent08f7fded3c097685af9370283fc8565b80fb0615 (diff)
downloadgitea-129b0d6a4b408555c579e7ccb2fb15d3d8fcef29.tar.gz
gitea-129b0d6a4b408555c579e7ccb2fb15d3d8fcef29.zip
Allow ENABLE_OPENID_SIGNUP to depend on DISABLE_REGISTRATION (#1369)
* Allow ENABLE_OPENID_SIGNUP to depend on DISABLE_REGISTRATION Omit the configuration variable (the default) to be dependent. Fixes #1363 * Move OpenID settings under Service object * Show OpenID SignUp and SignIn status in admin panel / configuration
Diffstat (limited to 'modules')
-rw-r--r--modules/context/context.go2
-rw-r--r--modules/setting/setting.go50
2 files changed, 27 insertions, 25 deletions
diff --git a/modules/context/context.go b/modules/context/context.go
index 52e50af6a1..e96bf5bd3f 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -197,7 +197,7 @@ func Contexter() macaron.Handler {
ctx.Data["ShowRegistrationButton"] = setting.Service.ShowRegistrationButton
ctx.Data["ShowFooterBranding"] = setting.ShowFooterBranding
ctx.Data["ShowFooterVersion"] = setting.ShowFooterVersion
- ctx.Data["EnableOpenIDSignIn"] = setting.EnableOpenIDSignIn
+ ctx.Data["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn
c.Map(ctx)
}
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 8c45e61e81..59cc755d03 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -121,12 +121,6 @@ var (
MinPasswordLength int
ImportLocalPaths bool
- // OpenID settings
- EnableOpenIDSignIn bool
- EnableOpenIDSignUp bool
- OpenIDWhitelist []*regexp.Regexp
- OpenIDBlacklist []*regexp.Regexp
-
// Database settings
UseSQLite3 bool
UseMySQL bool
@@ -758,24 +752,6 @@ please consider changing to GITEA_CUSTOM`)
MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt(6)
ImportLocalPaths = sec.Key("IMPORT_LOCAL_PATHS").MustBool(false)
- sec = Cfg.Section("openid")
- EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(true)
- EnableOpenIDSignUp = sec.Key("ENABLE_OPENID_SIGNUP").MustBool(true)
- pats := sec.Key("WHITELISTED_URIS").Strings(" ")
- if len(pats) != 0 {
- OpenIDWhitelist = make([]*regexp.Regexp, len(pats))
- for i, p := range pats {
- OpenIDWhitelist[i] = regexp.MustCompilePOSIX(p)
- }
- }
- pats = sec.Key("BLACKLISTED_URIS").Strings(" ")
- if len(pats) != 0 {
- OpenIDBlacklist = make([]*regexp.Regexp, len(pats))
- for i, p := range pats {
- OpenIDBlacklist[i] = regexp.MustCompilePOSIX(p)
- }
- }
-
sec = Cfg.Section("attachment")
AttachmentPath = sec.Key("PATH").MustString(path.Join(AppDataPath, "attachments"))
if !filepath.IsAbs(AttachmentPath) {
@@ -939,6 +915,13 @@ var Service struct {
EnableCaptcha bool
DefaultKeepEmailPrivate bool
NoReplyAddress string
+
+ // OpenID settings
+ EnableOpenIDSignIn bool
+ EnableOpenIDSignUp bool
+ OpenIDWhitelist []*regexp.Regexp
+ OpenIDBlacklist []*regexp.Regexp
+
}
func newService() {
@@ -953,6 +936,25 @@ func newService() {
Service.EnableCaptcha = sec.Key("ENABLE_CAPTCHA").MustBool()
Service.DefaultKeepEmailPrivate = sec.Key("DEFAULT_KEEP_EMAIL_PRIVATE").MustBool()
Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply.example.org")
+
+ sec = Cfg.Section("openid")
+ Service.EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(true)
+ Service.EnableOpenIDSignUp = sec.Key("ENABLE_OPENID_SIGNUP").MustBool(!Service.DisableRegistration)
+ pats := sec.Key("WHITELISTED_URIS").Strings(" ")
+ if len(pats) != 0 {
+ Service.OpenIDWhitelist = make([]*regexp.Regexp, len(pats))
+ for i, p := range pats {
+ Service.OpenIDWhitelist[i] = regexp.MustCompilePOSIX(p)
+ }
+ }
+ pats = sec.Key("BLACKLISTED_URIS").Strings(" ")
+ if len(pats) != 0 {
+ Service.OpenIDBlacklist = make([]*regexp.Regexp, len(pats))
+ for i, p := range pats {
+ Service.OpenIDBlacklist[i] = regexp.MustCompilePOSIX(p)
+ }
+ }
+
}
var logLevels = map[string]string{