who_need_help/lib/who_need_help_web/metrics_access.ex

12 lines
349 B
Elixir

defmodule WhoNeedHelpWeb.MetricsAccess do
@moduledoc false
def authorized?(["Bearer " <> candidate], expected)
when is_binary(expected) and expected != "" and
byte_size(candidate) == byte_size(expected) do
Plug.Crypto.secure_compare(candidate, expected)
end
def authorized?(_authorization, _expected), do: false
end