From be26662f3609b0f7495f31b742fdef1acd8cccbe Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Tue, 13 Apr 2021 11:19:24 +0300 Subject: [PATCH] Crash early if secret_key_base is not configured correctly --- config/runtime.exs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/config/runtime.exs b/config/runtime.exs index e1dc8c1ee..ce3896c9b 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -20,7 +20,17 @@ if base_url.scheme not in ["http", "https"] do }`" end -secret_key_base = System.fetch_env!("SECRET_KEY_BASE") +secret_key_base = + case System.get_env("SECRET_KEY_BASE") do + nil -> + raise "SECRET_KEY_BASE configuration option is required. See https://plausible.io/docs/self-hosting-configuration#server" + + key when byte_size(key) < 64 -> + raise "SECRET_KEY_BASE must be at least 64 bytes long. See https://plausible.io/docs/self-hosting-configuration#server" + + key -> + key + end db_url = System.get_env(