Fix http.Cookie SameSite is not copied. (#450)
* fix: http.Cookie SameSite is not copied.
* Update CHANGELOG.md
commit362cdf7713b7f3cb25647e6afd94f370d7c6cd7d
authorMitsuo Heijo <mitsuo.heijo@gmail.com>
dateWed 18 Mar 2020, 03:48 (7 years ago)
parent3108f76
CHANGELOG.md+1
@@ -9,6 +9,7 @@
99
1010## Changes since v5.0.0
1111
12+- [#450](https://github.com/pusher/oauth2_proxy/pull/450) Fix http.Cookie SameSite is not copied (@johejo)
1213- [#445](https://github.com/pusher/oauth2_proxy/pull/445) Expose `acr_values` to all providers (@holyjak)
1314- [#419](https://github.com/pusher/oauth2_proxy/pull/419) Support Go 1.14, upgrade dependencies, upgrade golangci-lint to 1.23.6 (@johejo)
1415- [#444](https://github.com/pusher/oauth2_proxy/pull/444) Support prompt in addition to approval-prompt (@holyjak)
pkg/sessions/cookie/session_store.go+1
@@ -207,5 +207,6 @@ func copyCookie(c *http.Cookie) *http.Cookie {
207207 HttpOnly: c.HttpOnly,
208208 Raw: c.Raw,
209209 Unparsed: c.Unparsed,
210+ SameSite: c.SameSite,
210211 }
211212}
pkg/sessions/cookie/session_store_test.gonew file+30
@@ -0,0 +1,30 @@
1+package cookie
2+
3+import (
4+ "net/http"
5+ "testing"
6+ "time"
7+
8+ "github.com/stretchr/testify/assert"
9+)
10+
11+func Test_copyCookie(t *testing.T) {
12+ expire, _ := time.Parse(time.RFC3339, "2020-03-17T00:00:00Z")
13+ c := &http.Cookie{
14+ Name: "name",
15+ Value: "value",
16+ Path: "/path",
17+ Domain: "x.y.z",
18+ Expires: expire,
19+ RawExpires: "rawExpire",
20+ MaxAge: 1,
21+ Secure: true,
22+ HttpOnly: true,
23+ Raw: "raw",
24+ Unparsed: []string{"unparsed"},
25+ SameSite: http.SameSiteLaxMode,
26+ }
27+
28+ got := copyCookie(c)
29+ assert.Equal(t, c, got)
30+}