Skip to content

Commit

Permalink
chore(ex/skate_web/endpoint): pull Plug.Session options into compil…
Browse files Browse the repository at this point in the history
  • Loading branch information
firestack authored Nov 14, 2024
1 parent 54be47c commit 7d54821
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions lib/skate_web/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@ defmodule SkateWeb.Endpoint do
use Sentry.PlugCapture
use Phoenix.Endpoint, otp_app: :skate

# The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it.
@session_options [
store: :cookie,
key: "_skate_key",
signing_salt: "jkUgGkwy",
same_site: "Lax"
]

socket "/socket", SkateWeb.UserSocket,
websocket: [check_origin: Application.compile_env(:skate, :websocket_check_origin, false)],
websocket: [
connect_info: [session: @session_options],
check_origin: Application.compile_env(:skate, :websocket_check_origin, false)
],
longpoll: false

# Serve at "/" the static files from "priv/static" directory.
Expand Down Expand Up @@ -36,14 +49,7 @@ defmodule SkateWeb.Endpoint do
plug Sentry.PlugContext
plug Plug.MethodOverride
plug Plug.Head

# The session will be stored in the cookie and signed,
# this means its contents can be read but not tampered with.
# Set :encryption_salt if you would also like to encrypt it.
plug Plug.Session,
store: :cookie,
key: "_skate_key",
signing_salt: "jkUgGkwy"
plug Plug.Session, @session_options

plug SkateWeb.Router
end

0 comments on commit 7d54821

Please sign in to comment.