File tree Expand file tree Collapse file tree 6 files changed +23
-3
lines changed Expand file tree Collapse file tree 6 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -468,6 +468,13 @@ INTERNAL_TOKEN =
468468; REVERSE_PROXY_AUTHENTICATION_EMAIL = X-WEBAUTH-EMAIL
469469; REVERSE_PROXY_AUTHENTICATION_FULL_NAME = X-WEBAUTH-FULLNAME
470470; ;
471+ ; ; URL or path that Gitea should redirect users to *before* performing its
472+ ; ; own logout. Use this when logout is handled by a reverse proxy or SSO.
473+ ; ; The external logout endpoint (reverse proxy / IdP) must then redirect
474+ ; ; the user back to /user/logout so Gitea can terminate its local session
475+ ; ; after the global SSO logout completes.
476+ ; REVERSE_PROXY_LOGOUT_REDIRECT = /mellon/logout?ReturnTo=/user/logout
477+ ; ;
471478; ; Interpret X-Forwarded-For header or the X-Real-IP header and set this as the remote IP for the request
472479; REVERSE_PROXY_LIMIT = 1
473480; ;
Original file line number Diff line number Diff line change 2424 ReverseProxyAuthUser string
2525 ReverseProxyAuthEmail string
2626 ReverseProxyAuthFullName string
27+ ReverseProxyLogoutRedirect string
2728 ReverseProxyLimit int
2829 ReverseProxyTrustedProxies []string
2930 MinPasswordLength int
@@ -119,7 +120,7 @@ func loadSecurityFrom(rootCfg ConfigProvider) {
119120 ReverseProxyAuthUser = sec .Key ("REVERSE_PROXY_AUTHENTICATION_USER" ).MustString ("X-WEBAUTH-USER" )
120121 ReverseProxyAuthEmail = sec .Key ("REVERSE_PROXY_AUTHENTICATION_EMAIL" ).MustString ("X-WEBAUTH-EMAIL" )
121122 ReverseProxyAuthFullName = sec .Key ("REVERSE_PROXY_AUTHENTICATION_FULL_NAME" ).MustString ("X-WEBAUTH-FULLNAME" )
122-
123+ ReverseProxyLogoutRedirect = sec . Key ( "REVERSE_PROXY_LOGOUT_REDIRECT" ). MustString ( "" )
123124 ReverseProxyLimit = sec .Key ("REVERSE_PROXY_LIMIT" ).MustInt (1 )
124125 ReverseProxyTrustedProxies = sec .Key ("REVERSE_PROXY_TRUSTED_PROXIES" ).Strings ("," )
125126 if len (ReverseProxyTrustedProxies ) == 0 {
Original file line number Diff line number Diff line change @@ -139,6 +139,9 @@ func NewFuncMap() template.FuncMap {
139139 "MermaidMaxSourceCharacters" : func () int {
140140 return setting .MermaidMaxSourceCharacters
141141 },
142+ "ReverseProxyLogoutRedirect" : func () string {
143+ return setting .ReverseProxyLogoutRedirect
144+ },
142145
143146 // -----------------------------------------------------------------
144147 // render
Original file line number Diff line number Diff line change @@ -416,6 +416,10 @@ func SignOut(ctx *context.Context) {
416416 })
417417 }
418418 HandleSignOut (ctx )
419+ if ctx .Req .Method == http .MethodGet {
420+ ctx .Redirect (setting .AppSubURL + "/" )
421+ return
422+ }
419423 ctx .JSONRedirect (setting .AppSubURL + "/" )
420424}
421425
Original file line number Diff line number Diff line change @@ -694,6 +694,7 @@ func registerWebRoutes(m *web.Router) {
694694 m .Post ("/recover_account" , auth .ResetPasswdPost )
695695 m .Get ("/forgot_password" , auth .ForgotPasswd )
696696 m .Post ("/forgot_password" , auth .ForgotPasswdPost )
697+ m .Get ("/logout" , auth .SignOut )
697698 m .Post ("/logout" , auth .SignOut )
698699 m .Get ("/stopwatches" , reqSignIn , user .GetStopwatches )
699700 m .Get ("/search_candidates" , optExploreSignIn , user .SearchCandidates )
Original file line number Diff line number Diff line change 5555 </div>
5656
5757 <div class="divider"></div>
58- <a class="item link-action" href data-url="{{AppSubUrl}}/user/logout">
58+ <a class="item {{if not ReverseProxyLogoutRedirect}}link-action{{end}}"
59+ {{if ReverseProxyLogoutRedirect}}href="{{ReverseProxyLogoutRedirect}}"
60+ {{else}}href data-url="{{AppSubUrl}}/user/logout"{{end}}>
5961 {{svg "octicon-sign-out"}}
6062 {{ctx.Locale.Tr "sign_out"}}
6163 </a>
128130 </a>
129131 {{end}}
130132 <div class="divider"></div>
131- <a class="item link-action" href data-url="{{AppSubUrl}}/user/logout">
133+ <a class="item {{if not ReverseProxyLogoutRedirect}}link-action{{end}}"
134+ {{if ReverseProxyLogoutRedirect}}href="{{ReverseProxyLogoutRedirect}}"
135+ {{else}}href data-url="{{AppSubUrl}}/user/logout"{{end}}>
132136 {{svg "octicon-sign-out"}}
133137 {{ctx.Locale.Tr "sign_out"}}
134138 </a>
You can’t perform that action at this time.
0 commit comments