livebook/lib/livebook_web/session_identity.ex
Cristine Guadelupe 550869c356
ZTA - Google IAP and adjustments (#2033)
* Fix GoogleIAP certs and fields

* Email as name when name is not available

* Initial docs

* Update lib/livebook_web/live/hooks/user_hook.ex

Co-authored-by: José Valim <jose.valim@gmail.com>

---------

Co-authored-by: José Valim <jose.valim@gmail.com>
2023-07-03 21:42:04 +02:00

19 lines
499 B
Elixir

defmodule LivebookWeb.SessionIdentity do
@moduledoc false
# This module implements the ZTA contract specific to Livebook cookies
import Plug.Conn
def authenticate(_, conn, _) do
if id = get_session(conn, :current_user_id) do
{conn, %{id: id}}
else
user_id = Livebook.Utils.random_id()
{put_session(conn, :current_user_id, user_id), %{id: user_id}}
end
end
def child_spec(_opts) do
%{id: __MODULE__, start: {Function, :identity, [:ignore]}}
end
end