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
