Skip to content

Commit

Permalink
add support for redir query parameter at logout endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
equinox0815 committed Nov 13, 2023
1 parent e20455a commit 189b1cc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/whawty-nginx-sso/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 189b1cc

Please sign in to comment.