ap: don't require explicit addressing of personal-inbox owners
This requirement was originally added together with splicing the inbox owner into the non b* addressing fields to make bcc transports work in https://git.pleroma.social/pleroma/pleroma/-/merge_requests/390. Later on this was relaxed to always allow deliveries devoid of any addressing at all inf6cb963df2and always allow deliveries from actors the owner is following in750b369d04to fix interop issues with Mastodon and Honk respectively. The justification for both the filtering and splicing comes from one sentence in AP spec’s inbox section: > In general, the owner of an inbox is likely > to be able to access all of their inbox contents. While this may provide plausible justification for splicing the owner into cc, it is less clear how this requires or justifies the set of filtering rules employed here. Surveying a few other implementations no similar filtering or splicing appears to be employed. Furthermore, spec-compliant servers will strip bto/bcc _before_ delivery to remote servers, meaning any compliant bcc transport out there will NOT contain any explicit addressing of the inbox owner. Thus the addressing requirement directly opposes the goal of the original patch. Currently the requirement for the owner to be addressed once again is causing interop issues. It turns out to be the root cause of a long-standing (2+ years) bug preventing meaningful federation. Bridgy sends e.g. Follow activities and Accepts for Follows directly to the affected user’s personal inbox while solely addressing the public scope in the to field. Notably follow relations never getting established prevented the "accept if followed" allow rule to ever come into effect. To make matters worse non-addressed messages simply lead to a vague "internal server error" response being sent back which likely slowed down locating the issue. Furthermore additional issues wrt to signatures cropped up after the 500-response issues wa first reported, but they seem to have already been fixed in the meantime, possibly with the signature handling overhaul in Akkoma. Given it repeatedly caused issues, does not appear to align with common practice in the wider fedi ecosystem and apparently contradicts its original intention, simply remove the requirement. This is confirmed to fix bridgy interop. The addressing splicing actually should also add the inbox owner to bto or bcc instead of cc, but for now this is not changed and in practice bto/bcc delivery appears to be basically unused anyway.
This commit is contained in:
parent
dbce9675e8
commit
2b885288fa
3 changed files with 0 additions and 82 deletions
|
|
@ -304,8 +304,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|
|||
|
||||
def inbox(%{assigns: %{valid_signature: true}} = conn, %{"nickname" => nickname} = params) do
|
||||
with %User{} = recipient <- User.get_cached_by_nickname(nickname),
|
||||
{:ok, %User{} = actor} <- User.get_or_fetch_by_ap_id(params["actor"]),
|
||||
true <- Utils.recipient_in_message(recipient, actor, params),
|
||||
params <- Utils.maybe_splice_recipient(recipient.ap_id, params) do
|
||||
Federator.incoming_ap_doc(params)
|
||||
json(conn, "ok")
|
||||
|
|
|
|||
|
|
@ -76,18 +76,6 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
|||
[params["to"], params["cc"], params["bto"], params["bcc"]]
|
||||
|> Enum.any?(&label_in_collection?(label, &1))
|
||||
|
||||
@spec unaddressed_message?(map()) :: boolean()
|
||||
def unaddressed_message?(params),
|
||||
do:
|
||||
[params["to"], params["cc"], params["bto"], params["bcc"]]
|
||||
|> Enum.all?(&is_nil(&1))
|
||||
|
||||
@spec recipient_in_message(User.t(), User.t(), map()) :: boolean()
|
||||
def recipient_in_message(%User{ap_id: ap_id} = recipient, %User{} = actor, params),
|
||||
do:
|
||||
label_in_message?(ap_id, params) || unaddressed_message?(params) ||
|
||||
User.following?(recipient, actor)
|
||||
|
||||
defp extract_list(target) when is_binary(target), do: [target]
|
||||
defp extract_list(lst) when is_list(lst), do: lst
|
||||
defp extract_list(_), do: []
|
||||
|
|
|
|||
|
|
@ -332,74 +332,6 @@ defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "recipient_in_message/3" do
|
||||
test "returns true when recipient in `to`" do
|
||||
recipient = insert(:user)
|
||||
actor = insert(:user)
|
||||
assert Utils.recipient_in_message(recipient, actor, %{"to" => recipient.ap_id})
|
||||
|
||||
assert Utils.recipient_in_message(
|
||||
recipient,
|
||||
actor,
|
||||
%{"to" => [recipient.ap_id], "cc" => ""}
|
||||
)
|
||||
end
|
||||
|
||||
test "returns true when recipient in `cc`" do
|
||||
recipient = insert(:user)
|
||||
actor = insert(:user)
|
||||
assert Utils.recipient_in_message(recipient, actor, %{"cc" => recipient.ap_id})
|
||||
|
||||
assert Utils.recipient_in_message(
|
||||
recipient,
|
||||
actor,
|
||||
%{"cc" => [recipient.ap_id], "to" => ""}
|
||||
)
|
||||
end
|
||||
|
||||
test "returns true when recipient in `bto`" do
|
||||
recipient = insert(:user)
|
||||
actor = insert(:user)
|
||||
assert Utils.recipient_in_message(recipient, actor, %{"bto" => recipient.ap_id})
|
||||
|
||||
assert Utils.recipient_in_message(
|
||||
recipient,
|
||||
actor,
|
||||
%{"bcc" => "", "bto" => [recipient.ap_id]}
|
||||
)
|
||||
end
|
||||
|
||||
test "returns true when recipient in `bcc`" do
|
||||
recipient = insert(:user)
|
||||
actor = insert(:user)
|
||||
assert Utils.recipient_in_message(recipient, actor, %{"bcc" => recipient.ap_id})
|
||||
|
||||
assert Utils.recipient_in_message(
|
||||
recipient,
|
||||
actor,
|
||||
%{"bto" => "", "bcc" => [recipient.ap_id]}
|
||||
)
|
||||
end
|
||||
|
||||
test "returns true when message without addresses fields" do
|
||||
recipient = insert(:user)
|
||||
actor = insert(:user)
|
||||
assert Utils.recipient_in_message(recipient, actor, %{"bccc" => recipient.ap_id})
|
||||
|
||||
assert Utils.recipient_in_message(
|
||||
recipient,
|
||||
actor,
|
||||
%{"btod" => "", "bccc" => [recipient.ap_id]}
|
||||
)
|
||||
end
|
||||
|
||||
test "returns false" do
|
||||
recipient = insert(:user)
|
||||
actor = insert(:user)
|
||||
refute Utils.recipient_in_message(recipient, actor, %{"to" => "ap_id"})
|
||||
end
|
||||
end
|
||||
|
||||
describe "lazy_put_activity_defaults/2" do
|
||||
test "returns map with id and published data" do
|
||||
note_activity = insert(:note_activity)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue