From fb3ffeb18df6bb94bb3f69348a93398b05259174 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 10 Jun 2021 01:53:16 +0800 Subject: 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 --- routers/api/v1/api.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'routers/api') 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, })) -- cgit v1.2.3