2022-01-06 23:31:26 +08:00
|
|
|
defmodule LivebookWeb.Socket do
|
|
|
|
use Phoenix.Socket
|
|
|
|
|
2022-02-28 20:53:33 +08:00
|
|
|
channel "js_view", LivebookWeb.JSViewChannel
|
2022-01-06 23:31:26 +08:00
|
|
|
|
|
|
|
@impl true
|
2022-02-08 04:03:25 +08:00
|
|
|
def connect(_params, socket, info) do
|
2022-01-06 23:31:26 +08:00
|
|
|
auth_mode = Livebook.Config.auth_mode()
|
|
|
|
|
|
|
|
if LivebookWeb.AuthPlug.authenticated?(info.session || %{}, info.uri.port, auth_mode) do
|
2022-02-08 04:03:25 +08:00
|
|
|
{:ok, socket}
|
2022-01-06 23:31:26 +08:00
|
|
|
else
|
|
|
|
:error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@impl true
|
2022-02-08 04:03:25 +08:00
|
|
|
def id(_socket), do: nil
|
2022-01-06 23:31:26 +08:00
|
|
|
end
|