aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAriadne Conill <ariadne@dereferenced.org>2019-07-18 16:01:21 +0000
committerAriadne Conill <ariadne@dereferenced.org>2019-07-18 16:01:21 +0000
commit5ea0cd69f7457086fc486f13e072f13d2c1ef547 (patch)
treeb7d01ccd5081e2e2329b174350d4598d5c00f5c7 /lib
parentcdf0038d0f5d56cf78f640fb149e9141e74800fc (diff)
downloadpleroma-5ea0cd69f7457086fc486f13e072f13d2c1ef547.tar.gz
mapped signature plug: don't invalidate in cases where a signature is actually not present (testsuite)
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/plugs/mapped_signature_to_identity_plug.ex16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/pleroma/plugs/mapped_signature_to_identity_plug.ex b/lib/pleroma/plugs/mapped_signature_to_identity_plug.ex
index ae9339595..2a8ed4470 100644
--- a/lib/pleroma/plugs/mapped_signature_to_identity_plug.ex
+++ b/lib/pleroma/plugs/mapped_signature_to_identity_plug.ex
@@ -36,12 +36,18 @@ defmodule Pleroma.Web.Plugs.MappedSignatureToIdentityPlug do
# if this has payload make sure it is signed by the same actor that made it
def call(%{assigns: %{valid_signature: true}, params: %{"actor" => actor}} = conn, _opts) do
with actor_id <- Utils.get_ap_id(actor),
- %User{} = user <- user_from_key_id(conn),
- true <- user.ap_id == actor_id do
+ {:user, %User{} = user} <- {:user, user_from_key_id(conn)},
+ {:user_match, true} <- {:user_match, user.ap_id == actor_id} do
assign(conn, :mapped_identity, user)
else
- _ ->
- Logger.debug("Failed to map identity from signature (payload actor mismatch?)")
+ {:user_match, false} ->
+ Logger.debug("Failed to map identity from signature (payload actor mismatch)")
+ Logger.debug("key_id=#{key_id_from_conn(conn)}, actor=#{actor}")
+ assign(conn, :valid_signature, false)
+
+ # remove me once testsuite uses mapped capabilities instead of what we do now
+ {:user, nil} ->
+ Logger.debug("Failed to map identity from signature (lookup failure)")
Logger.debug("key_id=#{key_id_from_conn(conn)}, actor=#{actor}")
conn
end
@@ -55,7 +61,7 @@ defmodule Pleroma.Web.Plugs.MappedSignatureToIdentityPlug do
_ ->
Logger.debug("Failed to map identity from signature (no payload actor mismatch)")
Logger.debug("key_id=#{key_id_from_conn(conn)}")
- conn
+ assign(conn, :valid_signature, false)
end
end