aboutsummaryrefslogtreecommitdiff
path: root/patches/5spoof.diff
diff options
context:
space:
mode:
Diffstat (limited to 'patches/5spoof.diff')
-rw-r--r--patches/5spoof.diff67
1 files changed, 67 insertions, 0 deletions
diff --git a/patches/5spoof.diff b/patches/5spoof.diff
new file mode 100644
index 0000000..718bfc4
--- /dev/null
+++ b/patches/5spoof.diff
@@ -0,0 +1,67 @@
+diff --git a/config/config.exs b/config/config.exs
+index 5d2e3b5ea1a3821629bc3025c1992c3cc21ff2f5..643e77c176e8dec2c304403a4240df8d77c19999 100644
+--- a/config/config.exs
++++ b/config/config.exs
+@@ -362,7 +362,13 @@
+ follow_handshake_timeout: 500,
+ note_replies_output_limit: 5,
+ sign_object_fetches: true,
+- authorized_fetch_mode: false
++ authorized_fetch_mode: false,
++ spoof_object_fetch_signatures: false,
++ spoofed_key: "-----BEGIN RSA PRIVATE KEY-----
++overwrite this with your internal.fetch key rippen from donor instance DB
++yes, just like that, newlines are important
++-----END RSA PRIVATE KEY-----",
++ spoofed_instance: "https://funnydomain.example"
+
+ config :pleroma, :streamer,
+ workers: 3,
+diff --git a/lib/pleroma/object/fetcher.ex b/lib/pleroma/object/fetcher.ex
+index deb3dc711598fb94dcee37a04bd1e55317fa5b88..6bc8d8ed71dd3e8a373eaf1420227c9c072bba5c 100644
+--- a/lib/pleroma/object/fetcher.ex
++++ b/lib/pleroma/object/fetcher.ex
+@@ -3,7 +3,10 @@
+ # SPDX-License-Identifier: AGPL-3.0-only
+
+ defmodule Pleroma.Object.Fetcher do
++ @behaviour HTTPSignatures.Adapter
++
+ alias Pleroma.HTTP
++ alias Pleroma.Keys
+ alias Pleroma.Maps
+ alias Pleroma.Object
+ alias Pleroma.Object.Containment
+@@ -161,13 +164,31 @@ def fetch_object_from_id!(id, options \\ []) do
+ defp make_signature(id, date) do
+ uri = URI.parse(id)
+
+- signature =
++ spoofed_pem = Pleroma.Config.get([:activitypub, :spoofed_key])
++ # workaround for syntax shite disallowing me from defining signature in "if" block
++ spoofed_key = if Pleroma.Config.get([:activitypub, :spoof_object_fetch_signatures]) do
++ with {:ok, private_key, _} <- Keys.keys_from_pem(spoofed_pem) do
++ private_key
++ end
++ else
++ ""
++ end
++ spoofed_instance = Pleroma.Config.get([:activitypub, :spoofed_instance])
++
++ signature = if Pleroma.Config.get([:activitypub, :spoof_object_fetch_signatures]) do
++ HTTPSignatures.sign(spoofed_key, spoofed_instance <> "/internal/fetch#main-key", %{
++ "(request-target)": "get #{uri.path}",
++ host: uri.host,
++ date: date
++ })
++ else
+ InternalFetchActor.get_actor()
+ |> Signature.sign(%{
+ "(request-target)": "get #{uri.path}",
+ host: uri.host,
+ date: date
+ })
++ end
+
+ {"signature", signature}
+ end