git.iko.soy/typeable/oauth2-proxy
on master help sign in
Merge pull request #510 from ploxiln/clear_invalid_session

more robust ClearSessionCookie()

commit1209c63b58507986df469c0aba8de60100afd477 authorTanvir Alam <talam@users.noreply.github.com> dateTue 16 Jan 2018, 10:57 (9 years ago) parent1a8218074d0fbc
1 file changed+9−1
oauthproxy.go+9−1
oauthproxy.go+9−1
@@ -300,7 +300,15 @@ func (p *OAuthProxy) SetCSRFCookie(rw http.ResponseWriter, req *http.Request, va
300300}
301301
302302func (p *OAuthProxy) ClearSessionCookie(rw http.ResponseWriter, req *http.Request) {
303− http.SetCookie(rw, p.MakeSessionCookie(req, "", time.Hour*-1, time.Now()))
303+ clr := p.MakeSessionCookie(req, "", time.Hour*-1, time.Now())
304+ http.SetCookie(rw, clr)
305+
306+ // ugly hack because default domain changed
307+ if p.CookieDomain == "" {
308+ clr2 := *clr
309+ clr2.Domain = req.Host
310+ http.SetCookie(rw, &clr2)
311+ }
304312}
305313
306314func (p *OAuthProxy) SetSessionCookie(rw http.ResponseWriter, req *http.Request, val string) {