Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuomo Ala-Vannesluoma <tuomoav@gmail.com>2018-08-18 10:08:58 +0300
committerTuomo Ala-Vannesluoma <tuomoav@gmail.com>2018-08-18 10:08:58 +0300
commitaf8b9cd5df9bf6331b9494149d2e402d30bcea81 (patch)
tree14aaace87e04f70bb1cccfa350e1a1cb9ad1cce1 /internal
parent240293f844ff22e19924644aa27815b6ca54735e (diff)
Fix the cookie domain by using the SplitHostAndPort
Diffstat (limited to 'internal')
-rw-r--r--internal/auth/auth.go8
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")