fix(federation): prevent fetching own relay actor
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -12,6 +12,7 @@ defmodule Mobilizon.Federation.HTTPSignatures.Signature do
|
||||
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Federation.ActivityPub.Actor, as: ActivityPubActor
|
||||
alias Mobilizon.Federation.ActivityPub.Relay
|
||||
|
||||
require Logger
|
||||
|
||||
@@ -94,13 +95,19 @@ defmodule Mobilizon.Federation.HTTPSignatures.Signature do
|
||||
%{"keyId" => kid} = HTTPSignatures.signature_for_conn(conn)
|
||||
actor_url = key_id_to_actor_url(kid)
|
||||
Logger.debug("Refetching public key for #{actor_url}")
|
||||
relay = Relay.get_actor()
|
||||
|
||||
# In this specific case we don't sign object fetches because
|
||||
# this would cause infinite recursion when servers both need
|
||||
# to fetch each other's keys
|
||||
with {:ok, %Actor{} = actor} <-
|
||||
ActivityPubActor.make_actor_from_url(actor_url, ignore_sign_object_fetches: true) do
|
||||
get_actor_public_key(actor)
|
||||
if actor_url == relay.url do
|
||||
# Special case if ever it's our own actor fetching ourselves
|
||||
get_actor_public_key(relay)
|
||||
else
|
||||
# In this specific case we don't sign object fetches because
|
||||
# this would cause infinite recursion when servers both need
|
||||
# to fetch each other's keys
|
||||
with {:ok, %Actor{} = actor} <-
|
||||
ActivityPubActor.make_actor_from_url(actor_url, ignore_sign_object_fetches: true) do
|
||||
get_actor_public_key(actor)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user