diff options
| author | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2021-11-10 00:37:27 +0100 | 
|---|---|---|
| committer | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2021-11-10 01:11:35 +0100 | 
| commit | 23e91ec8ddb143353b5f685feec33c64370d13c6 (patch) | |
| tree | e2f32e9191e725ef0df2950f3269794911d32d5d /lib | |
| parent | 6b5c2d5f866f748c20417517035f4814955d01dd (diff) | |
| download | pleroma-23e91ec8ddb143353b5f685feec33c64370d13c6.tar.gz pleroma-23e91ec8ddb143353b5f685feec33c64370d13c6.zip | |
activity_pub_controller: Fix misleading debug warning in post_inbox_fallback
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub_controller.ex | 37 | 
1 files changed, 17 insertions, 20 deletions
| diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index 57ac40b42..4a19938f6 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -283,15 +283,29 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do      json(conn, "ok")    end +  def inbox(%{assigns: %{valid_signature: false}} = conn, _params) do +    conn +    |> put_status(:bad_request) +    |> json("Invalid HTTP Signature") +  end +    # POST /relay/inbox -or- POST /internal/fetch/inbox -  def inbox(conn, params) do -    if params["type"] == "Create" && FederatingPlug.federating?() do +  def inbox(conn, %{"type" => "Create"} = params) do +    if FederatingPlug.federating?() do        post_inbox_relayed_create(conn, params)      else -      post_inbox_fallback(conn, params) +      conn +      |> put_status(:bad_request) +      |> json("Not federating")      end    end +  def inbox(conn, _params) do +    conn +    |> put_status(:bad_request) +    |> json("error, missing HTTP Signature") +  end +    defp post_inbox_relayed_create(conn, params) do      Logger.debug(        "Signature missing or not from author, relayed Create message, fetching object from source" @@ -302,23 +316,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do      json(conn, "ok")    end -  defp post_inbox_fallback(conn, params) do -    headers = Enum.into(conn.req_headers, %{}) - -    if headers["signature"] && params["actor"] && -         String.contains?(headers["signature"], params["actor"]) do -      Logger.debug( -        "Signature validation error for: #{params["actor"]}, make sure you are forwarding the HTTP Host header!" -      ) - -      Logger.debug(inspect(conn.req_headers)) -    end - -    conn -    |> put_status(:bad_request) -    |> json(dgettext("errors", "error")) -  end -    defp represent_service_actor(%User{} = user, conn) do      with {:ok, user} <- User.ensure_keys_present(user) do        conn | 
