activitypub: sign http date header
This commit is contained in:
parent
1c87102d01
commit
f8a72f2997
|
@ -823,11 +823,16 @@ def publish_one(%{inbox: inbox, json: json, actor: actor, id: id} = params) do
|
||||||
|
|
||||||
digest = "SHA-256=" <> (:crypto.hash(:sha256, json) |> Base.encode64())
|
digest = "SHA-256=" <> (:crypto.hash(:sha256, json) |> Base.encode64())
|
||||||
|
|
||||||
|
date =
|
||||||
|
NaiveDateTime.utc_now()
|
||||||
|
|> Timex.format!("{WDshort}, {D} {Mshort} {YYYY} {h24}:{m}:{s} GMT")
|
||||||
|
|
||||||
signature =
|
signature =
|
||||||
Pleroma.Web.HTTPSignatures.sign(actor, %{
|
Pleroma.Web.HTTPSignatures.sign(actor, %{
|
||||||
host: host,
|
host: host,
|
||||||
"content-length": byte_size(json),
|
"content-length": byte_size(json),
|
||||||
digest: digest
|
digest: digest,
|
||||||
|
date: date
|
||||||
})
|
})
|
||||||
|
|
||||||
with {:ok, %{status: code}} when code in 200..299 <-
|
with {:ok, %{status: code}} when code in 200..299 <-
|
||||||
|
@ -837,6 +842,7 @@ def publish_one(%{inbox: inbox, json: json, actor: actor, id: id} = params) do
|
||||||
json,
|
json,
|
||||||
[
|
[
|
||||||
{"Content-Type", "application/activity+json"},
|
{"Content-Type", "application/activity+json"},
|
||||||
|
{"Date", date},
|
||||||
{"signature", signature},
|
{"signature", signature},
|
||||||
{"digest", digest}
|
{"digest", digest}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue