ExTwilioWebhook.Plug (ex_twilio_webhook v0.0.3)
A module plug that verifies Twilio webhook signatures and halts the request if the signature is invalid.
This plug relies on parsed params, so it must be placed in your
Phoenix pipeline after Plug.Parsers
.
Link to this section Summary
Functions
Checks whether a request matches the given path pattern and passes it through if it doesn't.
Parses the plug's configuration options
Does the actual webhook validation.
Link to this section Functions
call(conn, settings)
Checks whether a request matches the given path pattern and passes it through if it doesn't.
init(opts)
Parses the plug's configuration options:
at
: the request path at which the plug will validate webhook signatures. When given a string, it will only match if therequest_path
is equal to the pattern. When given a regular expression, it will match if the regular expression matches therequest_path
.secret
: Twilio secret. The secret can be provided as a string, an{m, f, a}
tuple, or an anonymous function of arity 0 or 1. When given a 1-arity function, the function will be called with the value of theAccountSid
of each request. This is useful if your application needs to process webhooks from multiple Twilo accounts. When given an{m, f, a}
tuple, the tuple will be called at runtime for each request.public_host
: The public URL of your application with scheme, e. g.:https://myapp.com
. Can be provided as string or{m, f, a}
tuple. When given a tuple, the tuple will be called at runtime for each request.
This function will raise if called with invalid arguments.
normalize_request_url(public_host, conn)
path_matched?(path, regex)
validate_webhook(conn, settings)
Does the actual webhook validation.