validate webhook
This commit is contained in:
@@ -7,6 +7,9 @@ class SendTestWebhookRequestJob
|
||||
|
||||
USER_AGENT = 'DocuSeal.com Webhook'
|
||||
|
||||
HttpsError = Class.new(StandardError)
|
||||
LocalhostError = Class.new(StandardError)
|
||||
|
||||
def perform(params = {})
|
||||
submitter = Submitter.find_by(id: params['submitter_id'])
|
||||
|
||||
@@ -16,6 +19,17 @@ class SendTestWebhookRequestJob
|
||||
|
||||
return unless webhook_url
|
||||
|
||||
if Docuseal.multitenant?
|
||||
uri = begin
|
||||
URI(webhook_url.url)
|
||||
rescue URI::Error
|
||||
Addressable::URI.parse(webhook_url.url).normalize
|
||||
end
|
||||
|
||||
raise HttpsError, 'Only HTTPS is allowed.' if uri.scheme != 'https'
|
||||
raise LocalhostError, "Can't send to localhost." if uri.host.in?(SendWebhookRequest::LOCALHOSTS)
|
||||
end
|
||||
|
||||
Faraday.post(webhook_url.url,
|
||||
{
|
||||
event_type: 'form.completed',
|
||||
|
||||
Reference in New Issue
Block a user