mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-04 20:14:57 +08:00
Always redirect / to /apps if using teams auth
This commit is contained in:
parent
17bd9ebdde
commit
3cc66a6ab9
4 changed files with 15 additions and 2 deletions
|
@ -24,7 +24,7 @@ config :mime, :types, %{
|
||||||
}
|
}
|
||||||
|
|
||||||
config :livebook,
|
config :livebook,
|
||||||
agent_name: "livebook-agent",
|
agent_name: "default",
|
||||||
allowed_uri_schemes: [],
|
allowed_uri_schemes: [],
|
||||||
app_service_name: nil,
|
app_service_name: nil,
|
||||||
app_service_url: nil,
|
app_service_url: nil,
|
||||||
|
@ -37,6 +37,7 @@ config :livebook,
|
||||||
plugs: [],
|
plugs: [],
|
||||||
rewrite_on: [],
|
rewrite_on: [],
|
||||||
shutdown_callback: nil,
|
shutdown_callback: nil,
|
||||||
|
teams_auth?: false,
|
||||||
teams_url: "https://teams.livebook.dev",
|
teams_url: "https://teams.livebook.dev",
|
||||||
update_instructions_url: nil,
|
update_instructions_url: nil,
|
||||||
within_iframe: false
|
within_iframe: false
|
||||||
|
|
|
@ -259,6 +259,8 @@ defmodule Livebook.Application do
|
||||||
|
|
||||||
cond do
|
cond do
|
||||||
teams_key && auth ->
|
teams_key && auth ->
|
||||||
|
Application.put_env(:livebook, :teams_auth?, true)
|
||||||
|
|
||||||
case String.split(auth, ":") do
|
case String.split(auth, ":") do
|
||||||
["offline", name, public_key] ->
|
["offline", name, public_key] ->
|
||||||
create_offline_hub(teams_key, 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)
|
Application.get_env(:livebook, :iframe_url)
|
||||||
end
|
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 """
|
@doc """
|
||||||
Returns the configured URL for the Livebook Teams endpoint.
|
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
|
defp redirect_to_authenticate(%{path_info: []} = conn) do
|
||||||
path =
|
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"
|
~p"/apps"
|
||||||
else
|
else
|
||||||
~p"/authenticate"
|
~p"/authenticate"
|
||||||
|
|
Loading…
Add table
Reference in a new issue