Skip to content

Commit

Permalink
Set SameSite attribute to "Strict"
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Kumpf committed Aug 21, 2020
1 parent 95bc0ae commit 615dfdf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
3 changes: 2 additions & 1 deletion lib/teslamate_web/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ defmodule TeslaMateWeb.Endpoint do
@session_options [
store: :cookie,
key: "_teslamate_key",
signing_salt: "yt5O3CAQ"
signing_salt: "yt5O3CAQ",
same_site: "Strict"
]

socket "/live", Phoenix.LiveView.Socket,
Expand Down
13 changes: 4 additions & 9 deletions lib/teslamate_web/plugs/donate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@ defmodule TeslaMateWeb.Plugs.Donate do
def call(conn, _opts), do: put_donate_cookie(conn)

defp put_donate_cookie(conn) do
cond do
importing_data?() ->
put_resp_cookie(conn, "donate", "0", max_age: @max_age)

Release.seconds_since_last_migration() < @max_age / 2 ->
put_resp_cookie(conn, "donate", "0", max_age: @max_age)

true ->
conn
if importing_data?() or Release.seconds_since_last_migration() < @max_age / 2 do
put_resp_cookie(conn, "donate", "0", max_age: @max_age, same_site: "Strict")
else
conn
end
end

Expand Down

0 comments on commit 615dfdf

Please sign in to comment.