diff options
author | William Pitcock <nenolod@dereferenced.org> | 2018-07-31 23:17:47 +0000 |
---|---|---|
committer | William Pitcock <nenolod@dereferenced.org> | 2018-07-31 23:24:30 +0000 |
commit | 8da406afa2a53f1769e2a1a3a5e99571f30f8dea (patch) | |
tree | 34122ce92e6dcd3a8f4c1cc252ff4811e5ab5fee /lib/pleroma/plugs/digest.ex | |
parent | 2890aef9e8924a6ddc170034679b7313372b3567 (diff) | |
download | pleroma-8da406afa2a53f1769e2a1a3a5e99571f30f8dea.tar.gz |
activitypub: verify remote http signature digests by recomputing the digest and replacing the digest header
Diffstat (limited to 'lib/pleroma/plugs/digest.ex')
-rw-r--r-- | lib/pleroma/plugs/digest.ex | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/pleroma/plugs/digest.ex b/lib/pleroma/plugs/digest.ex new file mode 100644 index 000000000..9d6bbb085 --- /dev/null +++ b/lib/pleroma/plugs/digest.ex @@ -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 |