aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2019-01-29 13:12:28 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2019-01-29 13:12:28 +0300
commit92753b0cd9cfcdc5edb64a5e55ad27f73079f9e0 (patch)
tree606de2d652366d27ce34faebf3ad4274facfd15d /lib
parentd3f9e6f6fed382ede8e314c370c21e84a119f65a (diff)
downloadpleroma-92753b0cd9cfcdc5edb64a5e55ad27f73079f9e0.tar.gz
[#534] Made federation push sender be determined basing on content instead of `referer` header. Updated tests.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/plugs/set_requester_reachable_plug.ex16
-rw-r--r--lib/pleroma/reverse_proxy.ex3
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex3
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub_controller.ex11
-rw-r--r--lib/pleroma/web/ostatus/ostatus.ex3
-rw-r--r--lib/pleroma/web/ostatus/ostatus_controller.ex1
-rw-r--r--lib/pleroma/web/salmon/salmon.ex5
-rw-r--r--lib/pleroma/web/websub/websub.ex3
-rw-r--r--lib/pleroma/web/websub/websub_controller.ex2
9 files changed, 17 insertions, 30 deletions
diff --git a/lib/pleroma/plugs/set_requester_reachable_plug.ex b/lib/pleroma/plugs/set_requester_reachable_plug.ex
deleted file mode 100644
index 88551be70..000000000
--- a/lib/pleroma/plugs/set_requester_reachable_plug.ex
+++ /dev/null
@@ -1,16 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Web.Plugs.SetRequesterReachablePlug do
- import Plug.Conn
-
- def init(_), do: []
-
- def call(%Plug.Conn{} = conn, _) do
- with [referer] <- get_req_header(conn, "referer"),
- do: Pleroma.Instances.set_reachable(referer)
-
- conn
- end
-end
diff --git a/lib/pleroma/reverse_proxy.ex b/lib/pleroma/reverse_proxy.ex
index d8b17212b..a25b5ea4e 100644
--- a/lib/pleroma/reverse_proxy.ex
+++ b/lib/pleroma/reverse_proxy.ex
@@ -3,8 +3,7 @@
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ReverseProxy do
- @keep_req_headers ~w(accept user-agent accept-encoding cache-control if-modified-since if-unmodified-since) ++
- ~w(if-none-match if-range range referer)
+ @keep_req_headers ~w(accept user-agent accept-encoding cache-control if-modified-since if-unmodified-since if-none-match if-range range)
@resp_cache_headers ~w(etag date last-modified cache-control)
@keep_resp_headers @resp_cache_headers ++
~w(content-type content-disposition content-encoding content-range accept-ranges vary)
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index 22c7824fa..4016808e8 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -784,8 +784,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
[
{"Content-Type", "application/activity+json"},
{"signature", signature},
- {"digest", digest},
- {"referer", Pleroma.Web.Endpoint.url()}
+ {"digest", digest}
]
) do
Instances.set_reachable(inbox)
diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex
index fadb038a2..4dea6ab83 100644
--- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex
@@ -18,7 +18,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
action_fallback(:errors)
plug(Pleroma.Web.FederatingPlug when action in [:inbox, :relay])
- plug(Pleroma.Web.Plugs.SetRequesterReachablePlug when action in [:inbox])
+ plug(:set_requester_reachable when action in [:inbox])
plug(:relay_active? when action in [:relay])
def relay_active?(conn, _) do
@@ -291,4 +291,13 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|> put_status(500)
|> json("error")
end
+
+ defp set_requester_reachable(%Plug.Conn{} = conn, _) do
+ with actor <- conn.params["actor"],
+ true <- is_binary(actor) do
+ Pleroma.Instances.set_reachable(actor)
+ end
+
+ conn
+ end
end
diff --git a/lib/pleroma/web/ostatus/ostatus.ex b/lib/pleroma/web/ostatus/ostatus.ex
index a3155b79d..a20ca17bb 100644
--- a/lib/pleroma/web/ostatus/ostatus.ex
+++ b/lib/pleroma/web/ostatus/ostatus.ex
@@ -48,6 +48,9 @@ defmodule Pleroma.Web.OStatus do
def handle_incoming(xml_string) do
with doc when doc != :error <- parse_document(xml_string) do
+ with {:ok, actor_user} <- find_make_or_update_user(doc),
+ do: Pleroma.Instances.set_reachable(actor_user.ap_id)
+
entries = :xmerl_xpath.string('//entry', doc)
activities =
diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex
index 9392a97f0..302ff38a4 100644
--- a/lib/pleroma/web/ostatus/ostatus_controller.ex
+++ b/lib/pleroma/web/ostatus/ostatus_controller.ex
@@ -14,7 +14,6 @@ defmodule Pleroma.Web.OStatus.OStatusController do
alias Pleroma.Web.ActivityPub.ActivityPub
plug(Pleroma.Web.FederatingPlug when action in [:salmon_incoming])
- plug(Pleroma.Web.Plugs.SetRequesterReachablePlug when action in [:salmon_incoming])
action_fallback(:errors)
diff --git a/lib/pleroma/web/salmon/salmon.ex b/lib/pleroma/web/salmon/salmon.ex
index e96455423..07ca42a5f 100644
--- a/lib/pleroma/web/salmon/salmon.ex
+++ b/lib/pleroma/web/salmon/salmon.ex
@@ -172,10 +172,7 @@ defmodule Pleroma.Web.Salmon do
poster.(
url,
feed,
- [
- {"Content-Type", "application/magic-envelope+xml"},
- {"referer", Pleroma.Web.Endpoint.url()}
- ]
+ [{"Content-Type", "application/magic-envelope+xml"}]
) do
Instances.set_reachable(url)
Logger.debug(fn -> "Pushed to #{url}, code #{code}" end)
diff --git a/lib/pleroma/web/websub/websub.ex b/lib/pleroma/web/websub/websub.ex
index abe148270..8f7d53b03 100644
--- a/lib/pleroma/web/websub/websub.ex
+++ b/lib/pleroma/web/websub/websub.ex
@@ -278,8 +278,7 @@ defmodule Pleroma.Web.Websub do
xml,
[
{"Content-Type", "application/atom+xml"},
- {"X-Hub-Signature", "sha1=#{signature}"},
- {"referer", Pleroma.Web.Endpoint.url()}
+ {"X-Hub-Signature", "sha1=#{signature}"}
]
) do
Instances.set_reachable(callback)
diff --git a/lib/pleroma/web/websub/websub_controller.ex b/lib/pleroma/web/websub/websub_controller.ex
index 9da7e70a1..a92dfe87b 100644
--- a/lib/pleroma/web/websub/websub_controller.ex
+++ b/lib/pleroma/web/websub/websub_controller.ex
@@ -20,8 +20,6 @@ defmodule Pleroma.Web.Websub.WebsubController do
]
)
- plug(Pleroma.Web.Plugs.SetRequesterReachablePlug when action in [:websub_incoming])
-
def websub_subscription_request(conn, %{"nickname" => nickname} = params) do
user = User.get_cached_by_nickname(nickname)