1 # Akkoma: Magically expressive social media
2 # Copyright © 2022-2022 Akkoma Authors <https://akkoma.dev/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Plugs.EnsureHTTPSignaturePlug do
7 Ensures HTTP signature has been validated by previous plugs on ActivityPub requests.
10 import Phoenix.Controller, only: [get_format: 1, text: 2]
18 def call(%{assigns: %{valid_signature: true}} = conn, _), do: conn
21 with true <- get_format(conn) in ["json", "activity+json"],
22 true <- Config.get([:activitypub, :authorized_fetch_mode], true) do
24 |> put_status(:unauthorized)
25 |> text("Request not signed")