activitypub: verify remote http signature digests by recomputing the digest and replacing the digest header

This commit is contained in:
William Pitcock 2018-07-31 23:17:47 +00:00
commit 8da406afa2
3 changed files with 22 additions and 1 deletions

View file

@ -0,0 +1,10 @@
defmodule Pleroma.Web.Plugs.DigestPlug do
alias Plug.Conn
require Logger
def read_body(conn, opts) do
{:ok, body, conn} = Conn.read_body(conn, opts)
digest = "SHA-256=" <> (:crypto.hash(:sha256, body) |> Base.encode64())
{:ok, body, Conn.assign(conn, :digest, digest)}
end
end