diff options
author | Roger Braun <roger@rogerbraun.net> | 2017-12-11 10:37:40 +0100 |
---|---|---|
committer | Roger Braun <roger@rogerbraun.net> | 2017-12-11 10:37:40 +0100 |
commit | c3bcafc51bdf17db1bab157524b42b4fc46690b1 (patch) | |
tree | e991fb2ed885a4e030b590ad4b91d9dc18ab6e78 /lib | |
parent | 5599c5920c293ac993146e21a73520213bbe2a8a (diff) | |
download | pleroma-c3bcafc51bdf17db1bab157524b42b4fc46690b1.tar.gz |
HTTPSig: Add method to validate conn
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/http_signatures/http_signatures.ex | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/pleroma/web/http_signatures/http_signatures.ex b/lib/pleroma/web/http_signatures/http_signatures.ex index 65a344e0b..8603cb671 100644 --- a/lib/pleroma/web/http_signatures/http_signatures.ex +++ b/lib/pleroma/web/http_signatures/http_signatures.ex @@ -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) |