Add "Disable SSL Verification" button to mattermost notification

This commit will add a button which will disable SSL notifications
for the mattermost webhook. This is required when using self-signed
certificates.
This commit is contained in:
Nicholas O. Wilburn 2017-09-14 16:17:02 -07:00
parent cd3ba08c7d
commit 68d240b77b
2 changed files with 12 additions and 3 deletions

View File

@ -14,16 +14,18 @@ logger = logging.getLogger('awx.main.notifications.mattermost_backend')
class MattermostBackend(AWXBaseEmailBackend):
init_parameters = {"mattermost_url": {"label": "Target URL", "type": "string"}}
init_parameters = {"mattermost_url": {"label": "Target URL", "type": "string"},
"mattermost_no_verify_ssl": {"label": "Verify SSL", "type": "bool"}}
recipient_parameter = "mattermost_url"
sender_parameter = None
def __init__(self, mattermost_channel=None, mattermost_username=None,
def __init__(self, mattermost_no_verify_ssl=False, mattermost_channel=None, mattermost_username=None,
mattermost_icon_url=None, fail_silently=False, **kwargs):
super(MattermostBackend, self).__init__(fail_silently=fail_silently)
self.mattermost_channel = mattermost_channel
self.mattermost_username = mattermost_username
self.mattermost_icon_url = mattermost_icon_url
self.mattermost_no_verify_ssl = mattermost_no_verify_ssl
def format_body(self, body):
return body
@ -41,7 +43,7 @@ class MattermostBackend(AWXBaseEmailBackend):
payload['text'] = m.subject
r = requests.post("{}".format(m.recipients()[0]),
data=json.dumps(payload))
data=json.dumps(payload), verify=(not self.mattermost_no_verify_ssl))
if r.status_code >= 400:
logger.error(smart_text(_("Error sending notification mattermost: {}").format(r.text)))
if not self.fail_silently:

View File

@ -365,6 +365,13 @@ export default ['i18n', function(i18n) {
subForm: 'typeSubForm',
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
},
mattermost_no_verify_ssl: {
label: i18n._('Disable SSL Verification'),
type: 'checkbox',
ngShow: "notification_type.value == 'mattermost' ",
subForm: 'typeSubForm',
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)'
},
server: {
label: i18n._('IRC Server Address'),
type: 'text',