summaryrefslogtreecommitdiffstats
path: root/routers/web
diff options
context:
space:
mode:
authorGeorge Tsiamasiotis <gtsiam@windowslive.com>2024-11-26 07:51:51 +0100
committerSquel <squeljur+git@gmail.com>2024-12-01 15:50:10 +0100
commita126477e866c5d28b3dbe51f5e3ce97dffcbf199 (patch)
tree782f651f6b5772011ecc28f1f8c72b33fe8bc5dc /routers/web
parentMerge pull request 'Improve Swagger documentation for user endpoints' (#6050)... (diff)
downloadforgejo-a126477e866c5d28b3dbe51f5e3ce97dffcbf199.tar.xz
forgejo-a126477e866c5d28b3dbe51f5e3ce97dffcbf199.zip
feat: Add option to disable builtin authentication.
Setting ENABLE_INTERNAL_SIGNIN to false will disable the built-in signin form, should the administrator prefer to limit users to SSO. Continuation of forgejo/forgejo#6076
Diffstat (limited to 'routers/web')
-rw-r--r--routers/web/auth/auth.go8
1 files changed, 8 insertions, 0 deletions
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)