mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-01-30 10:47:51 +08:00
Make configs consistent
This commit is contained in:
parent
1cd92366d8
commit
27e7535a42
4 changed files with 19 additions and 11 deletions
|
@ -206,9 +206,6 @@ The following environment variables configure Livebook:
|
|||
* LIVEBOOK_SHUTDOWN_ENABLED - controls if a shutdown button should be shown
|
||||
in the homepage. Set it to "true" to enable it.
|
||||
|
||||
* LIVEBOOK_WITHIN_IFRAME - controls if the application is running inside an
|
||||
iframe. Set it to "true" to enable it.
|
||||
|
||||
* LIVEBOOK_TOKEN_ENABLED - controls whether token authentication is enabled.
|
||||
Enabled by default unless `LIVEBOOK_PASSWORD` is set. Set it to "false" to
|
||||
disable it.
|
||||
|
@ -216,6 +213,10 @@ The following environment variables configure Livebook:
|
|||
* LIVEBOOK_UPDATE_INSTRUCTIONS_URL - sets the URL to direct the user to for
|
||||
updating Livebook when a new version becomes available.
|
||||
|
||||
* LIVEBOOK_WITHIN_IFRAME - controls if the application is running inside an
|
||||
iframe. Set it to "true" to enable it. If you do enable it, then the application
|
||||
must run with HTTPS.
|
||||
|
||||
<!-- Environment variables -->
|
||||
|
||||
If running Livebook as a Docker image or an Elixir release, [the environment
|
||||
|
|
|
@ -23,12 +23,14 @@ config :livebook,
|
|||
app_service_name: nil,
|
||||
app_service_url: nil,
|
||||
authentication_mode: :token,
|
||||
learn_notebooks: [],
|
||||
feature_flags: [],
|
||||
force_ssl_host: nil,
|
||||
learn_notebooks: [],
|
||||
plugs: [],
|
||||
shutdown_enabled: false,
|
||||
within_iframe: false,
|
||||
storage: Livebook.Storage.Ets
|
||||
storage: Livebook.Storage.Ets,
|
||||
update_instructions_url: nil,
|
||||
within_iframe: false
|
||||
|
||||
# Import environment specific config. This must remain at the bottom
|
||||
# of this file so it overrides the configuration defined above.
|
||||
|
|
|
@ -143,7 +143,14 @@ defmodule Livebook.Config do
|
|||
"""
|
||||
@spec update_instructions_url() :: String.t() | nil
|
||||
def update_instructions_url() do
|
||||
Application.get_env(:livebook, :update_instructions_url)
|
||||
Application.fetch_env!(:livebook, :update_instructions_url)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns the force ssl host if any.
|
||||
"""
|
||||
def force_ssl_host do
|
||||
Application.fetch_env!(:livebook, :force_ssl_host)
|
||||
end
|
||||
|
||||
@feature_flags Application.compile_env(:livebook, :feature_flags)
|
||||
|
|
|
@ -94,11 +94,9 @@ defmodule LivebookWeb.Endpoint do
|
|||
end
|
||||
end
|
||||
|
||||
@plug_ssl Plug.SSL.init(host: {Application, :get_env, [:livebook, :force_ssl_host, nil]})
|
||||
@plug_ssl Plug.SSL.init(host: {Livebook.Config, :force_ssl_host, []})
|
||||
def force_ssl(conn, _opts) do
|
||||
force_ssl_host = Application.get_env(:livebook, :force_ssl_host, nil)
|
||||
|
||||
if force_ssl_host do
|
||||
if Livebook.Config.force_ssl_host() do
|
||||
Plug.SSL.call(conn, @plug_ssl)
|
||||
else
|
||||
conn
|
||||
|
|
Loading…
Reference in a new issue