From 189b1cc76269c0a55d68bd3f012d112614600522 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 13 Nov 2023 17:29:58 +0100 Subject: [PATCH] add support for redir query parameter at logout endpoint --- cmd/whawty-nginx-sso/web.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/whawty-nginx-sso/web.go b/cmd/whawty-nginx-sso/web.go index 32bc902..274c430 100644 --- a/cmd/whawty-nginx-sso/web.go +++ b/cmd/whawty-nginx-sso/web.go @@ -162,7 +162,11 @@ func (h *HandlerContext) handleLoginPost(c *gin.Context) { func (h *HandlerContext) handleLogout(c *gin.Context) { opts := h.cookies.Options() c.SetCookie(opts.Name, "invalid", -1, "/", opts.Domain, opts.Secure, true) - c.Redirect(http.StatusSeeOther, path.Join(h.getBasePath(c), "login")) // TODO follow redir?? + redirect, _ := c.GetQuery("redir") + if redirect == "" { + redirect = path.Join(h.getBasePath(c), "login") + } + c.Redirect(http.StatusSeeOther, redirect) } func runWeb(config *WebConfig, cookies *cookie.Controller, auth auth.Backend) (err error) {