]> source.dussan.org Git - gitea.git/commitdiff
Move reverproxyauth before session so the header will not be ignored even if user...
authorGiteabot <teabot@gitea.io>
Sun, 12 May 2024 02:26:01 +0000 (10:26 +0800)
committerGitHub <noreply@github.com>
Sun, 12 May 2024 02:26:01 +0000 (10:26 +0800)
Backport #27821 by @lunny

When a user logout and then login another user, the reverseproxy auth
should be checked before session otherwise the old user is still login.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
routers/web/web.go

index bbda234115a221fd47d740db769edc48a7025e83..25716f718129eed390a3960e33e5cc14b7fdcb11 100644 (file)
@@ -100,14 +100,14 @@ func optionsCorsHandler() func(next http.Handler) http.Handler {
 // The Session plugin is expected to be executed second, in order to skip authentication
 // for users that have already signed in.
 func buildAuthGroup() *auth_service.Group {
-       group := auth_service.NewGroup(
-               &auth_service.OAuth2{}, // FIXME: this should be removed and only applied in download and oauth related routers
-               &auth_service.Basic{},  // FIXME: this should be removed and only applied in download and git/lfs routers
-               &auth_service.Session{},
-       )
+       group := auth_service.NewGroup()
+       group.Add(&auth_service.OAuth2{}) // FIXME: this should be removed and only applied in download and oauth related routers
+       group.Add(&auth_service.Basic{})  // FIXME: this should be removed and only applied in download and git/lfs routers
+
        if setting.Service.EnableReverseProxyAuth {
-               group.Add(&auth_service.ReverseProxy{})
+               group.Add(&auth_service.ReverseProxy{}) // reverseproxy should before Session, otherwise the header will be ignored if user has login
        }
+       group.Add(&auth_service.Session{})
 
        if setting.IsWindows && auth_model.IsSSPIEnabled() {
                group.Add(&auth_service.SSPI{}) // it MUST be the last, see the comment of SSPI