Add "Disable SSL Verification" checkbox to webhook notification

This commit will add a checkbox which will disable SSL verification on
the generic webhook notification type. This is required when using
self-signed certificates.
This commit is contained in:
zicklam
2019-05-06 13:12:41 +02:00
parent e5cf5be18d
commit 5b8fba58e8
2 changed files with 12 additions and 2 deletions

View File

@@ -15,11 +15,13 @@ logger = logging.getLogger('awx.main.notifications.webhook_backend')
class WebhookBackend(AWXBaseEmailBackend):
init_parameters = {"url": {"label": "Target URL", "type": "string"},
"webhook_no_verify_ssl": {"label": "Verify SSL", "type": "bool"},
"headers": {"label": "HTTP Headers", "type": "object"}}
recipient_parameter = "url"
sender_parameter = None
def __init__(self, headers, fail_silently=False, **kwargs):
def __init__(self, headers, webhook_no_verify_ssl=False, fail_silently=False, **kwargs):
self.webhook_no_verify_ssl = webhook_no_verify_ssl
self.headers = headers
super(WebhookBackend, self).__init__(fail_silently=fail_silently)
@@ -33,7 +35,8 @@ class WebhookBackend(AWXBaseEmailBackend):
for m in messages:
r = requests.post("{}".format(m.recipients()[0]),
json=m.body,
headers=self.headers)
headers=self.headers,
verify=(not self.webhook_no_verify_ssl))
if r.status_code >= 400:
logger.error(smart_text(_("Error sending notification webhook: {}").format(r.text)))
if not self.fail_silently: