@ -3,7 +3,6 @@
# SPDX-License-Identifier: AGPL-3.0-only
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Plugs.HTTPSignaturePlug do
defmodule Pleroma.Web.Plugs.HTTPSignaturePlug do
alias Pleroma.Web.ActivityPub.Utils
import Plug.Conn
import Plug.Conn
require Logger
require Logger
@ -16,12 +15,9 @@ defmodule Pleroma.Web.Plugs.HTTPSignaturePlug do
end
end
def call ( conn , _opts ) do
def call ( conn , _opts ) do
user = Utils . get_ap_id ( conn . params [ " actor " ] )
Logger . debug ( " Checking sig for #{ user } " )
[ signature | _ ] = get_req_header ( conn , " signature " )
[ signature | _ ] = get_req_header ( conn , " signature " )
cond do
if signature do
signature && String . contains? ( signature , user ) ->
# set (request-target) header to the appropriate value
# set (request-target) header to the appropriate value
# we also replace the digest header with the one we computed
# we also replace the digest header with the one we computed
conn =
conn =
@ -40,12 +36,7 @@ defmodule Pleroma.Web.Plugs.HTTPSignaturePlug do
end
end
assign ( conn , :valid_signature , HTTPSignatures . validate_conn ( conn ) )
assign ( conn , :valid_signature , HTTPSignatures . validate_conn ( conn ) )
else
signature ->
Logger . debug ( " Signature not from actor " )
assign ( conn , :valid_signature , false )
true ->
Logger . debug ( " No signature header! " )
Logger . debug ( " No signature header! " )
conn
conn
end
end