aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/web.go
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/web/web.go
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/web/web.go')
-rw-r--r--routers/web/web.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/routers/web/web.go b/routers/web/web.go
index 6c0141eef3..df9efe25d6 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -31,6 +31,7 @@ import (
"code.gitea.io/gitea/routers/web/repo"
"code.gitea.io/gitea/routers/web/user"
userSetting "code.gitea.io/gitea/routers/web/user/setting"
+ "code.gitea.io/gitea/services/auth"
"code.gitea.io/gitea/services/forms"
"code.gitea.io/gitea/services/lfs"
"code.gitea.io/gitea/services/mailer"
@@ -149,6 +150,9 @@ func Routes() *web.Route {
// Removed: toolbox.Toolboxer middleware will provide debug informations which seems unnecessary
common = append(common, context.Contexter())
+ // Get user from session if logged in.
+ common = append(common, context.Auth(auth.NewGroup(auth.Methods()...)))
+
// GetHead allows a HEAD request redirect to GET if HEAD method is not defined for that route
common = append(common, middleware.GetHead)