Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Bugfix: enable nameservers fallback when no DNS configured explicitly for SSO (#5530)

Adam Rutkowski69b180dc21cb
diff --git a/config/runtime.exs b/config/runtime.exs
index a23500b42b..2e928176e5 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -315,9 +315,9 @@ sso_saml_adapter =
sso_verification_nameservers =
case get_var_from_path_or_env(config_dir, "SSO_VERIFICATION_NAMESERVERS") do
nil ->
- []
+ nil
- some ->
+ some when is_binary(some) ->
some
|> String.split(",")
|> Enum.map(fn addr ->
diff --git a/extra/lib/plausible/auth/sso/domain/verification.ex b/extra/lib/plausible/auth/sso/domain/verification.ex
index f7f48192cc..d4996f8ef3 100644
--- a/extra/lib/plausible/auth/sso/domain/verification.ex
+++ b/extra/lib/plausible/auth/sso/domain/verification.ex
@@ -74,12 +74,20 @@ defmodule Plausible.Auth.SSO.Domain.Verification do
record_value = to_charlist("#{@prefix}=#{domain_identifier}")
timeout = Keyword.get(opts, :timeout, 5_000)
- nameservers = Keyword.get(opts, :nameservers, [])
- opts = [timeout: timeout, nameservers: nameservers]
+ nameservers = Keyword.get(opts, :nameservers)
+
+ lookup_opts =
+ case nameservers do
+ nil ->
+ [timeout: timeout]
+
+ [_ | _] ->
+ [timeout: timeout, nameservers: nameservers]
+ end
sso_domain
|> to_charlist()
- |> :inet_res.lookup(:in, :txt, opts, timeout)
+ |> :inet_res.lookup(:in, :txt, lookup_opts, timeout)
|> Enum.find_value(false, fn
[^record_value] -> true
_ -> false