diff --git a/config/config.exs b/config/config.exs index 9cd969ee2..1ad0e4b44 100644 --- a/config/config.exs +++ b/config/config.exs @@ -24,7 +24,7 @@ config :mime, :types, %{ } config :livebook, - agent_name: "livebook-agent", + agent_name: "default", allowed_uri_schemes: [], app_service_name: nil, app_service_url: nil, @@ -37,6 +37,7 @@ config :livebook, plugs: [], rewrite_on: [], shutdown_callback: nil, + teams_auth?: false, teams_url: "https://teams.livebook.dev", update_instructions_url: nil, within_iframe: false diff --git a/lib/livebook/application.ex b/lib/livebook/application.ex index f42394b5b..f5e98df59 100644 --- a/lib/livebook/application.ex +++ b/lib/livebook/application.ex @@ -259,6 +259,8 @@ defmodule Livebook.Application do cond do teams_key && auth -> + Application.put_env(:livebook, :teams_auth?, true) + case String.split(auth, ":") do ["offline", name, public_key] -> create_offline_hub(teams_key, name, public_key) diff --git a/lib/livebook/config.ex b/lib/livebook/config.ex index df1a6d694..45d5f7bf0 100644 --- a/lib/livebook/config.ex +++ b/lib/livebook/config.ex @@ -231,6 +231,15 @@ defmodule Livebook.Config do Application.get_env(:livebook, :iframe_url) end + @doc """ + Returns if this instance is running with teams auth, + i.e. if there an online or offline hub created on boot. + """ + @spec teams_auth?() :: boolean() + def teams_auth?() do + Application.fetch_env!(:livebook, :teams_auth?) + end + @doc """ Returns the configured URL for the Livebook Teams endpoint. """ diff --git a/lib/livebook_web/plugs/auth_plug.ex b/lib/livebook_web/plugs/auth_plug.ex index 35ba1e431..db6362cb3 100644 --- a/lib/livebook_web/plugs/auth_plug.ex +++ b/lib/livebook_web/plugs/auth_plug.ex @@ -77,7 +77,8 @@ defmodule LivebookWeb.AuthPlug do defp redirect_to_authenticate(%{path_info: []} = conn) do path = - if Livebook.Apps.list_apps() != [] or Livebook.Apps.empty_apps_path?() do + if Livebook.Apps.list_apps() != [] or Livebook.Config.apps_path() != nil or + Livebook.Config.teams_auth?() do ~p"/apps" else ~p"/authenticate"