diff --git a/CHANGELOG.md b/CHANGELOG.md index f20ca97f6..6201a36f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to Gogs are documented in this file. - Support using TLS for Redis session provider using `[session] PROVIDER_CONFIG = ...,tls=true`. [#7860](https://github.com/gogs/gogs/pull/7860) - Support expanading values in `app.ini` from environment variables, e.g. `[database] PASSWORD = ${DATABASE_PASSWORD}`. [#8057](https://github.com/gogs/gogs/pull/8057) +- Support custom logout URL that users get redirected to after sign out using `[auth] CUSTOM_LOGOUT_URL`. [#8089](https://github.com/gogs/gogs/pull/8089) - Start publishing next-generation, security-focused Docker image via `gogs/gogs:next-latest`, which will become the default image distribution (`gogs/gogs:latest`) starting 0.15.0. While not all container options support have been added in the next-generation image, the use of current legacy Docker image is deprecated, it will be published as `gogs/gogs:legacy-latest` starting 0.15.0, and be completely removed starting 0.16.0. [#8061](https://github.com/gogs/gogs/pull/8061) ### Changed diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index d39f709e7..14d39595f 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -1274,6 +1274,7 @@ config.email.test_mail_failed = Failed to send test email to '%s': %v config.email.test_mail_sent = Test email has been sent to '%s'. config.auth_config = Authentication configuration +config.auth_custom_logout_url = Custom logout URL config.auth.activate_code_lives = Activate code lives config.auth.reset_password_code_lives = Reset password code lives config.auth.require_email_confirm = Require email confirmation diff --git a/internal/conf/static.go b/internal/conf/static.go index 8d242a2bf..374a01ba9 100644 --- a/internal/conf/static.go +++ b/internal/conf/static.go @@ -249,6 +249,7 @@ type AuthOpts struct { EnableReverseProxyAuthentication bool EnableReverseProxyAutoRegistration bool ReverseProxyAuthenticationHeader string + CustomLogoutURL string `ini:"CUSTOM_LOGOUT_URL"` } // Authentication settings diff --git a/internal/conf/testdata/TestInit.golden.ini b/internal/conf/testdata/TestInit.golden.ini index 1f0e50b72..98907dbc5 100644 --- a/internal/conf/testdata/TestInit.golden.ini +++ b/internal/conf/testdata/TestInit.golden.ini @@ -107,6 +107,7 @@ ENABLE_REGISTRATION_CAPTCHA=true ENABLE_REVERSE_PROXY_AUTHENTICATION=false ENABLE_REVERSE_PROXY_AUTO_REGISTRATION=false REVERSE_PROXY_AUTHENTICATION_HEADER=X-FORWARDED-FOR +CUSTOM_LOGOUT_URL= [user] ENABLE_EMAIL_NOTIFICATION=true diff --git a/internal/route/user/auth.go b/internal/route/user/auth.go index fcccd313a..4b66fad06 100644 --- a/internal/route/user/auth.go +++ b/internal/route/user/auth.go @@ -287,6 +287,10 @@ func SignOut(c *context.Context) { c.SetCookie(conf.Security.CookieUsername, "", -1, conf.Server.Subpath) c.SetCookie(conf.Security.CookieRememberName, "", -1, conf.Server.Subpath) c.SetCookie(conf.Session.CSRFCookieName, "", -1, conf.Server.Subpath) + if conf.Auth.CustomLogoutURL != "" { + c.Redirect(conf.Auth.CustomLogoutURL) + return + } c.RedirectSubpath("/") } diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl index e84016ec3..a0e10100c 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -308,6 +308,14 @@
{{.i18n.Tr "admin.config.auth.reverse_proxy_authentication_header"}}
{{.Auth.ReverseProxyAuthenticationHeader}}
+
{{.i18n.Tr "admin.config.auth_custom_logout_url"}}
+
+ {{if .Auth.CustomLogoutURL}} + {{.Auth.CustomLogoutURL}} + {{else}} + {{.i18n.Tr "admin.config.not_set"}} + {{end}} +