Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ex/skate_web/endpoint): pull Plug.Session options into compile time constant #2894

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading