livebook/lib/livebook_web/channels/socket.ex
Jonatan Kłosko 4334e8a58e
Add access control to apps (#1715)
Co-authored-by: José Valim <jose.valim@dashbit.co>
2023-02-18 01:16:42 +01:00

20 lines
451 B
Elixir

defmodule LivebookWeb.Socket do
use Phoenix.Socket
channel "js_view", LivebookWeb.JSViewChannel
@impl true
def connect(_params, socket, info) do
# The session is present only if the CSRF token is valid. We rely
# on CSRF token, because we don't check connection origin as noted
# in LivebookWeb.Endpoint.
if info.session do
{:ok, socket}
else
:error
end
end
@impl true
def id(_socket), do: nil
end