mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-09-20 10:05:57 +08:00
Always redirect / to /apps if using teams auth
This commit is contained in:
parent
0e530f08e3
commit
2a5bb078a0
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
"""
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue