aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api')
-rw-r--r--routers/api/v1/api.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index f3efd67bb3..acee6329af 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -83,6 +83,7 @@ import (
"code.gitea.io/gitea/routers/api/v1/settings"
_ "code.gitea.io/gitea/routers/api/v1/swagger" // for swagger generation
"code.gitea.io/gitea/routers/api/v1/user"
+ "code.gitea.io/gitea/services/auth"
"code.gitea.io/gitea/services/forms"
"gitea.com/go-chi/binding"
@@ -573,6 +574,9 @@ func Routes() *web.Route {
}
m.Use(context.APIContexter())
+ // Get user from session if logged in.
+ m.Use(context.APIAuth(auth.NewGroup(auth.Methods()...)))
+
m.Use(context.ToggleAPI(&context.ToggleOptions{
SignInRequired: setting.Service.RequireSignInView,
}))