Allow multiple cookie domains to be specified (#412)

* Allow multiple cookie domains to be specified

* Use X-Forwarded-Host, if it exists, when selecting cookie domain

* Perform cookie domain sorting in config validation phase

* Extract get domain cookies to a single function

* Update pkg/cookies/cookies.go

Co-Authored-By: Joel Speed <Joel.speed@hotmail.co.uk>

* Update changelog

Co-authored-by: Marcos Lilljedahl <marcosnils@gmail.com>
Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk>
This commit is contained in:
Eric Dahlseng
2020-04-12 12:00:44 +01:00
committed by GitHub
co-authored by Joel Speed Marcos Lilljedahl
parent 7f72a22227
commit a659b9558e
9 changed files with 66 additions and 19 deletions
+6 -2
View File
@@ -63,7 +63,11 @@ var _ = Describe("NewSessionStore", func() {
It("have the correct domain set", func() {
for _, cookie := range cookies {
Expect(cookie.Domain).To(Equal(cookieOpts.CookieDomain))
specifiedDomain := ""
if len(cookieOpts.CookieDomains) > 0 {
specifiedDomain = cookieOpts.CookieDomains[0]
}
Expect(cookie.Domain).To(Equal(specifiedDomain))
}
})
@@ -343,7 +347,7 @@ var _ = Describe("NewSessionStore", func() {
CookieRefresh: time.Duration(2) * time.Hour,
CookieSecure: false,
CookieHTTPOnly: false,
CookieDomain: "example.com",
CookieDomains: []string{"example.com"},
CookieSameSite: "strict",
}