mirror of
https://github.com/docusealco/docuseal
synced 2026-11-16 00:12:32 -05:00
validate webhook
This commit is contained in:
1 parent
abf17eb09f
commit
964b5d4e74
1 file changed
+14
@@ -7,6 +7,9 @@ class SendTestWebhookRequestJob
|
|||||||
|
|
||||||
USER_AGENT = 'DocuSeal.com Webhook'
|
USER_AGENT = 'DocuSeal.com Webhook'
|
||||||
|
|
||||||
|
HttpsError = Class.new(StandardError)
|
||||||
|
LocalhostError = Class.new(StandardError)
|
||||||
|
|
||||||
def perform(params = {})
|
def perform(params = {})
|
||||||
submitter = Submitter.find_by(id: params['submitter_id'])
|
submitter = Submitter.find_by(id: params['submitter_id'])
|
||||||
|
|
||||||
@@ -16,6 +19,17 @@ class SendTestWebhookRequestJob
|
|||||||
|
|
||||||
return unless webhook_url
|
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,
|
Faraday.post(webhook_url.url,
|
||||||
{
|
{
|
||||||
event_type: 'form.completed',
|
event_type: 'form.completed',
|
||||||
|
|||||||
Reference in new issue
Block a user