HTTPSig: Add method to validate conn
This commit is contained in:
parent
5599c5920c
commit
c3bcafc51b
2 changed files with 29 additions and 0 deletions
|
|
@ -21,6 +21,12 @@ defmodule Pleroma.Web.HTTPSignatures do
|
|||
verify = :public_key.verify(sigstring, :sha256, sig, public_key)
|
||||
end
|
||||
|
||||
def validate_conn(conn, public_key) do
|
||||
headers = Enum.into(conn.req_headers, %{})
|
||||
signature = split_signature(headers["signature"])
|
||||
validate(headers, signature, public_key)
|
||||
end
|
||||
|
||||
def build_signing_string(headers, used_headers) do
|
||||
used_headers
|
||||
|> Enum.map(fn (header) -> "#{header}: #{headers[header]}" end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue