Make tests great again !
(Also use only one field for public/private key pem) Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -32,7 +32,7 @@ defmodule Eventos.Service.HTTPSignatures do
|
||||
# TODO: How to get the right key and see if it is actually valid for that request.
|
||||
# For now, fetch the key for the actor.
|
||||
with actor_id <- conn.params["actor"],
|
||||
{:ok, public_key_code} <- Actor.get_public_key_for_url(actor_id),
|
||||
public_key_code <- Actor.get_public_key_for_url(actor_id),
|
||||
[public_key] = :public_key.pem_decode(public_key_code),
|
||||
public_key = :public_key.pem_entry_decode(public_key) do
|
||||
if validate_conn(conn, public_key) do
|
||||
@@ -42,7 +42,7 @@ defmodule Eventos.Service.HTTPSignatures do
|
||||
# Fetch user anew and try one more time
|
||||
with actor_id <- conn.params["actor"],
|
||||
{:ok, _actor} <- ActivityPub.make_actor_from_url(actor_id),
|
||||
{:ok, public_key_code} <- Actor.get_public_key_for_url(actor_id),
|
||||
public_key_code <- Actor.get_public_key_for_url(actor_id),
|
||||
[public_key] = :public_key.pem_decode(public_key_code),
|
||||
public_key = :public_key.pem_entry_decode(public_key) do
|
||||
validate_conn(conn, public_key)
|
||||
@@ -70,10 +70,8 @@ defmodule Eventos.Service.HTTPSignatures do
|
||||
|> Enum.join("\n")
|
||||
end
|
||||
|
||||
def sign(actor, headers) do
|
||||
with {:ok, private_key_code} = Actor.get_private_key_for_actor(actor),
|
||||
[private_key] = :public_key.pem_decode(private_key_code),
|
||||
private_key = :public_key.pem_entry_decode(private_key) do
|
||||
def sign(%Actor{} = actor, headers) do
|
||||
with private_key = Actor.get_keys_for_actor(actor) do
|
||||
sigstring = build_signing_string(headers, Map.keys(headers))
|
||||
|
||||
signature =
|
||||
|
||||
Reference in New Issue
Block a user