aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-06-10 01:53:16 +0800
committerGitHub <noreply@github.com>2021-06-09 19:53:16 +0200
commitfb3ffeb18df6bb94bb3f69348a93398b05259174 (patch)
treeaa56433e062bc68d2a118581a715ee324f025594 /routers/api
parentda057996d584c633524406d69b424cbc3d4473eb (diff)
downloadgitea-fb3ffeb18df6bb94bb3f69348a93398b05259174.tar.gz
gitea-fb3ffeb18df6bb94bb3f69348a93398b05259174.zip
Add sso.Group, context.Auth, context.APIAuth to allow auth special routes (#16086)
* Add sso.Group, context.Auth, context.APIAuth to allow auth special routes * Remove unnecessary check * Rename sso -> auth * remove unused method of Auth interface
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,
}))