1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Plugs.HTTPSignaturePlug do
13 def call(%{assigns: %{valid_signature: true}} = conn, _opts) do
17 def call(conn, _opts) do
18 [signature | _] = get_req_header(conn, "signature")
21 # set (request-target) header to the appropriate value
22 # we also replace the digest header with the one we computed
27 String.downcase("#{conn.method}") <> " #{conn.request_path}"
31 if conn.assigns[:digest] do
33 |> put_req_header("digest", conn.assigns[:digest])
38 assign(conn, :valid_signature, HTTPSignatures.validate_conn(conn))
40 Logger.debug("No signature header!")