diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 7d508daa40..45b094d99c 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -901,6 +901,9 @@ LEVEL = Info ;; Show Registration button ;SHOW_REGISTRATION_BUTTON = true ;; +;; Whether to allow internal signin +; ENABLE_INTERNAL_SIGNIN = true +;; ;; Show milestones dashboard page - a view of all the user's milestones ;SHOW_MILESTONES_DASHBOARD_PAGE = true ;; diff --git a/modules/setting/service.go b/modules/setting/service.go index e630fe85b8..5a6cc254e0 100644 --- a/modules/setting/service.go +++ b/modules/setting/service.go @@ -43,6 +43,7 @@ var Service = struct { AllowOnlyInternalRegistration bool AllowOnlyExternalRegistration bool ShowRegistrationButton bool + EnableInternalSignIn bool ShowMilestonesDashboardPage bool RequireSignInView bool EnableNotifyMail bool @@ -175,6 +176,7 @@ func loadServiceFrom(rootCfg ConfigProvider) { Service.EmailDomainBlockList = append(Service.EmailDomainBlockList, toAdd...) } Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!(Service.DisableRegistration || Service.AllowOnlyExternalRegistration)) + Service.EnableInternalSignIn = sec.Key("ENABLE_INTERNAL_SIGNIN").MustBool(true) Service.ShowMilestonesDashboardPage = sec.Key("SHOW_MILESTONES_DASHBOARD_PAGE").MustBool(true) Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool() Service.EnableBasicAuth = sec.Key("ENABLE_BASIC_AUTHENTICATION").MustBool(true) diff --git a/routers/web/auth/auth.go b/routers/web/auth/auth.go index 941586db72..71d7b8ca11 100644 --- a/routers/web/auth/auth.go +++ b/routers/web/auth/auth.go @@ -164,6 +164,7 @@ func SignIn(ctx *context.Context) { ctx.Data["PageIsSignIn"] = true ctx.Data["PageIsLogin"] = true ctx.Data["EnableSSPI"] = auth.IsSSPIEnabled(ctx) + ctx.Data["EnableInternalSignIn"] = setting.Service.EnableInternalSignIn if setting.Service.EnableCaptcha && setting.Service.RequireCaptchaForLogin { context.SetCaptchaData(ctx) @@ -187,6 +188,13 @@ func SignInPost(ctx *context.Context) { ctx.Data["PageIsSignIn"] = true ctx.Data["PageIsLogin"] = true ctx.Data["EnableSSPI"] = auth.IsSSPIEnabled(ctx) + ctx.Data["EnableInternalSignIn"] = setting.Service.EnableInternalSignIn + + // Permission denied if EnableInternalSignIn is false + if !setting.Service.EnableInternalSignIn { + ctx.Error(http.StatusForbidden) + return + } if ctx.HasError() { ctx.HTML(http.StatusOK, tplSignIn) diff --git a/templates/user/auth/oauth_container.tmpl b/templates/user/auth/oauth_container.tmpl index bb6a10d408..ecae2bbbf3 100644 --- a/templates/user/auth/oauth_container.tmpl +++ b/templates/user/auth/oauth_container.tmpl @@ -1,7 +1,9 @@ {{if or .OAuth2Providers .EnableOpenIDSignIn}} +{{if .EnableInternalSignIn}}