diff options
Diffstat (limited to 'routers/web')
-rw-r--r-- | routers/web/base.go | 4 | ||||
-rw-r--r-- | routers/web/user/oauth.go | 4 | ||||
-rw-r--r-- | routers/web/web.go | 4 |
3 files changed, 8 insertions, 4 deletions
diff --git a/routers/web/base.go b/routers/web/base.go index 8a44736434..f079be51f0 100644 --- a/routers/web/base.go +++ b/routers/web/base.go @@ -15,7 +15,6 @@ import ( "strings" "code.gitea.io/gitea/models" - "code.gitea.io/gitea/modules/auth/sso" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/httpcache" "code.gitea.io/gitea/modules/log" @@ -23,6 +22,7 @@ import ( "code.gitea.io/gitea/modules/storage" "code.gitea.io/gitea/modules/templates" "code.gitea.io/gitea/modules/web/middleware" + "code.gitea.io/gitea/services/auth" "gitea.com/go-chi/session" ) @@ -158,7 +158,7 @@ func Recovery() func(next http.Handler) http.Handler { } if user == nil { // Get user from session if logged in - do not attempt to sign-in - user = sso.SessionUser(sessionStore) + user = auth.SessionUser(sessionStore) } if user != nil { store["IsSigned"] = true diff --git a/routers/web/user/oauth.go b/routers/web/user/oauth.go index 3ef5a56c01..3359c75020 100644 --- a/routers/web/user/oauth.go +++ b/routers/web/user/oauth.go @@ -13,13 +13,13 @@ import ( "strings" "code.gitea.io/gitea/models" - "code.gitea.io/gitea/modules/auth/sso" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/web" + "code.gitea.io/gitea/services/auth" "code.gitea.io/gitea/services/forms" "gitea.com/go-chi/binding" @@ -228,7 +228,7 @@ func InfoOAuth(ctx *context.Context) { ctx.HandleText(http.StatusUnauthorized, "no valid auth token authorization") return } - uid := sso.CheckOAuthAccessToken(auths[1]) + uid := auth.CheckOAuthAccessToken(auths[1]) if uid == 0 { handleBearerTokenError(ctx, BearerTokenError{ ErrorCode: BearerTokenErrorCodeInvalidToken, 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) |