Skip to content

Commit

Permalink
Merge pull request #18 from virtualq/dev-2584-validate-signalwire-req…
Browse files Browse the repository at this point in the history
…uests

[DEV-2584] feat: add signalwire-signature header
  • Loading branch information
cristofer authored Oct 23, 2024
2 parents f214c6e + 13594e9 commit 1b5e79f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/ex_twilio_webhook/plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ defmodule ExTwilioWebhook.Plug do
url = normalize_request_url(settings.public_host, conn)

# extract signature and raw body from the conn, and validate the signature
with [signature] <- get_req_header(conn, "x-twilio-signature"),
with [signature] <- get_provider_req_header(conn),
%{raw_body: payload} <- conn.private,
true <-
HashHelpers.validate_request_with_body(secret, signature, url, payload) do
Expand All @@ -100,6 +100,10 @@ defmodule ExTwilioWebhook.Plug do
end
end

defp get_provider_req_header(conn) do
get_req_header(conn, "x-twilio-signature") || get_req_header(conn, "x-signalwire-signature")
end

def validate_webhook(conn, _settings), do: deny_access(conn)

defp deny_access(conn) do
Expand Down

0 comments on commit 1b5e79f

Please sign in to comment.