Sign body contents for federation request if present
This commit is contained in:
parent
be9860f7d0
commit
46231b9b09
1 changed files with 4 additions and 1 deletions
|
@ -12,7 +12,7 @@ defmodule MatrixServerWeb.Federation.Middleware.SignRequest do
|
|||
|
||||
defp sign_request(env, false), do: env
|
||||
|
||||
defp sign_request(%Tesla.Env{method: method, url: path, opts: opts} = env, true) do
|
||||
defp sign_request(%Tesla.Env{method: method, url: path, opts: opts, body: body} = env, true) do
|
||||
origin = MatrixServer.server_name()
|
||||
|
||||
object_to_sign = %{
|
||||
|
@ -22,6 +22,9 @@ defmodule MatrixServerWeb.Federation.Middleware.SignRequest do
|
|||
destination: Keyword.fetch!(opts, :server_name)
|
||||
}
|
||||
|
||||
object_to_sign =
|
||||
if not is_nil(body), do: Map.put(object_to_sign, :content, body), else: object_to_sign
|
||||
|
||||
with {:ok, sig, key_id} <- MatrixServer.KeyServer.sign_object(object_to_sign) do
|
||||
sigs = %{origin => %{key_id => sig}}
|
||||
auth_headers = create_signature_authorization_headers(sigs, origin)
|
||||
|
|
Loading…
Reference in a new issue