Don't sign fetch when fetching actor for a given signature
Otherwise it's doing a loop Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
88067bd217
commit
84bd1ccfad
|
@ -13,7 +13,7 @@ defmodule Mobilizon.Federation.ActivityPub.Fetcher do
|
||||||
alias Mobilizon.Service.HTTP.ActivityPub, as: ActivityPubClient
|
alias Mobilizon.Service.HTTP.ActivityPub, as: ActivityPubClient
|
||||||
|
|
||||||
import Mobilizon.Federation.ActivityPub.Utils,
|
import Mobilizon.Federation.ActivityPub.Utils,
|
||||||
only: [maybe_date_fetch: 2, sign_fetch: 4, origin_check?: 2]
|
only: [maybe_date_fetch: 2, sign_fetch: 5, origin_check?: 2]
|
||||||
|
|
||||||
import Mobilizon.Service.Guards, only: [is_valid_string: 1]
|
import Mobilizon.Service.Guards, only: [is_valid_string: 1]
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ defmodule Mobilizon.Federation.ActivityPub.Fetcher do
|
||||||
headers =
|
headers =
|
||||||
[{:Accept, "application/activity+json"}]
|
[{:Accept, "application/activity+json"}]
|
||||||
|> maybe_date_fetch(date)
|
|> maybe_date_fetch(date)
|
||||||
|> sign_fetch(on_behalf_of, url, date)
|
|> sign_fetch(on_behalf_of, url, date, options)
|
||||||
|
|
||||||
client = ActivityPubClient.client(headers: headers)
|
client = ActivityPubClient.client(headers: headers)
|
||||||
|
|
||||||
|
|
|
@ -650,9 +650,10 @@ defmodule Mobilizon.Federation.ActivityPub.Utils do
|
||||||
@doc """
|
@doc """
|
||||||
Sign a request with an actor.
|
Sign a request with an actor.
|
||||||
"""
|
"""
|
||||||
@spec sign_fetch(Enum.t(), Actor.t(), String.t(), String.t()) :: Enum.t()
|
@spec sign_fetch(Enum.t(), Actor.t(), String.t(), String.t(), Keyword.t()) :: Enum.t()
|
||||||
def sign_fetch(headers, actor, id, date) do
|
def sign_fetch(headers, actor, id, date, options \\ []) do
|
||||||
if Mobilizon.Config.get([:activitypub, :sign_object_fetches]) do
|
if Mobilizon.Config.get([:activitypub, :sign_object_fetches]) and
|
||||||
|
Keyword.get(options, :ignore_sign_object_fetches, false) == false do
|
||||||
headers ++ make_signature(actor, id, date)
|
headers ++ make_signature(actor, id, date)
|
||||||
else
|
else
|
||||||
headers
|
headers
|
||||||
|
|
|
@ -103,8 +103,9 @@ defmodule Mobilizon.Federation.HTTPSignatures.Signature do
|
||||||
actor_id = key_id_to_actor_url(kid)
|
actor_id = key_id_to_actor_url(kid)
|
||||||
Logger.debug("Refetching public key for #{actor_id}")
|
Logger.debug("Refetching public key for #{actor_id}")
|
||||||
|
|
||||||
with {:ok, _actor} <- ActivityPubActor.make_actor_from_url(actor_id) do
|
with {:ok, %Actor{} = actor} <-
|
||||||
get_public_key_for_url(actor_id)
|
ActivityPubActor.make_actor_from_url(actor_url, ignore_sign_object_fetches: true) do
|
||||||
|
get_actor_public_key(actor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue