Always redirect / to /apps if using teams auth

This commit is contained in:
José Valim 2024-07-04 10:49:31 +02:00 committed by Jonatan Kłosko
parent 0e530f08e3
commit 2a5bb078a0
4 changed files with 15 additions and 2 deletions

View file

@ -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

View file

@ -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)

View file

@ -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.
"""

View file

@ -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"