Skip to content

Commit 7c00feb

Browse files
authored
fix(guard,rbac): Update same_site cookie policy to Lax (#193)
1 parent ffafe73 commit 7c00feb

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

ee/rbac/lib/rbac/utils/http.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ defmodule Rbac.Utils.Http do
55
@state_cookie_options [
66
encrypt: true,
77
max_age: 30 * 60,
8-
same_site: "Strict",
8+
# If `same_site` is set to `Strict` then the cookie will not be sent on
9+
# IdP callback redirects, which will break the auth flow.
10+
same_site: "Lax",
911
path: "/",
1012
secure: true,
1113
http_only: true

guard/lib/guard/utils.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ defmodule Guard.Utils.Http do
137137
@state_cookie_options [
138138
encrypt: true,
139139
max_age: 30 * 60,
140-
same_site: "Strict",
140+
# If `same_site` is set to `Strict` then the cookie will not be sent on
141+
# IdP callback redirects, which will break the auth flow.
142+
same_site: "Lax",
141143
path: "/",
142144
secure: true,
143145
http_only: true

guard/test/guard/id/api_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ defmodule Guard.Id.Api.Test do
476476
{_, cookie} = Enum.find(response.headers, fn h -> elem(h, 0) == "set-cookie" end)
477477

478478
assert cookie =~ "semaphore_auth_state="
479-
assert cookie =~ "secure; HttpOnly; SameSite=Strict"
479+
assert cookie =~ "secure; HttpOnly; SameSite=Lax"
480480

481481
assert response.body =~ "/protocol/openid-connect/auth"
482482
assert response.body =~ "localhost"

0 commit comments

Comments
 (0)