git.iko.soy/typeable/oauth2-proxy
on master help sign in
Fix - Refresh Session not working for multiple cookies (#1209) (#1227)
41cd418Rishi Kambil
CHANGELOG.md+1−1
@@ -7,7 +7,7 @@
7## Breaking Changes
7## Breaking Changes
8
8
9## Changes since v7.1.3
9## Changes since v7.1.3
10−
10+- [#1227](https://github.com/oauth2-proxy/oauth2-proxy/pull/1227) Fix Refresh Session not working for multiple cookies (@rishi1111)
11- [#1063](https://github.com/oauth2-proxy/oauth2-proxy/pull/1063) Add Redis lock feature to lock persistent sessions (@Bibob7)
11- [#1063](https://github.com/oauth2-proxy/oauth2-proxy/pull/1063) Add Redis lock feature to lock persistent sessions (@Bibob7)
12- [#1108](https://github.com/oauth2-proxy/oauth2-proxy/pull/1108) Add alternative ways to generate cookie secrets to docs (@JoelSpeed)
12- [#1108](https://github.com/oauth2-proxy/oauth2-proxy/pull/1108) Add alternative ways to generate cookie secrets to docs (@JoelSpeed)
13- [#1142](https://github.com/oauth2-proxy/oauth2-proxy/pull/1142) Add pagewriter to upstream proxy (@JoelSpeed)
13- [#1142](https://github.com/oauth2-proxy/oauth2-proxy/pull/1142) Add pagewriter to upstream proxy (@JoelSpeed)
pkg/middleware/headers.go+2−1
@@ -43,7 +43,8 @@ func newStripHeaders(headers []options.Header) alice.Constructor {
43
43
44func flattenHeaders(headers http.Header) {
44func flattenHeaders(headers http.Header) {
45 for name, values := range headers {
45 for name, values := range headers {
46+ // Set-Cookie should not be flattened, ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie
46− if len(values) > 1 {
47+ if len(values) > 1 && name != "Set-Cookie" {
47 headers.Set(name, strings.Join(values, ","))
48 headers.Set(name, strings.Join(values, ","))
48 }
49 }
49 }
50 }
pkg/middleware/headers_test.go+36
@@ -253,6 +253,42 @@ var _ = Describe("Headers Suite", func() {
253 },
253 },
254 expectedErr: "",
254 expectedErr: "",
255 }),
255 }),
256+
257+ Entry("with flattenHeaders (set-cookie and any other)", headersTableInput{
258+ headers: []options.Header{
259+ {
260+ Name: "Set-Cookie",
261+ Values: []options.HeaderValue{
262+ {
263+ SecretSource: &options.SecretSource{
264+ Value: []byte("_oauth2_proxy=ey123123123"),
265+ },
266+ },
267+ },
268+ },
269+ {
270+ Name: "X-Auth-User",
271+ Values: []options.HeaderValue{
272+ {
273+ SecretSource: &options.SecretSource{
274+ Value: []byte("oauth_user"),
275+ },
276+ },
277+ },
278+ },
279+ },
280+ initialHeaders: http.Header{
281+ "Set-Cookie": []string{"cookie1=value1", "cookie2=value2"},
282+ "X-Auth-User": []string{"oauth_user_1"},
283+ },
284+
285+ expectedHeaders: http.Header{
286+ "Set-Cookie": []string{"cookie1=value1", "cookie2=value2", "_oauth2_proxy=ey123123123"},
287+ "X-Auth-User": []string{"oauth_user_1,oauth_user"},
288+ },
289+ expectedErr: "",
290+ }),
291+
256 Entry("with a claim valued header", headersTableInput{
292 Entry("with a claim valued header", headersTableInput{
257 headers: []options.Header{
293 headers: []options.Header{
258 {
294 {