diff options
author | Tuomo Ala-Vannesluoma <tuomoav@gmail.com> | 2018-08-18 10:08:58 +0300 |
---|---|---|
committer | Tuomo Ala-Vannesluoma <tuomoav@gmail.com> | 2018-08-18 10:08:58 +0300 |
commit | af8b9cd5df9bf6331b9494149d2e402d30bcea81 (patch) | |
tree | 14aaace87e04f70bb1cccfa350e1a1cb9ad1cce1 | |
parent | 240293f844ff22e19924644aa27815b6ca54735e (diff) |
Fix the cookie domain by using the SplitHostAndPort
-rw-r--r-- | internal/auth/auth.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/auth/auth.go b/internal/auth/auth.go index da6789dc..f2f21537 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "net" "net/http" "strings" "sync" @@ -54,10 +55,15 @@ type errorResponse struct { func (a *Auth) getSessionFromStore(r *http.Request) (*sessions.Session, error) { store := sessions.NewCookieStore([]byte(a.storeSecret)) + host, _, err := net.SplitHostPort(r.Host) + if err != nil { + host = r.Host + } + // Cookie just for this domain store.Options = &sessions.Options{ Path: "/", - Domain: r.Host, + Domain: host, } return store.Get(r, "gitlab-pages") |