mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
Enforce http_method restrictions via API
This commit is contained in:
@@ -4237,6 +4237,8 @@ class NotificationTemplateSerializer(BaseSerializer):
|
|||||||
continue
|
continue
|
||||||
if field_type == "password" and field_val == "$encrypted$" and object_actual is not None:
|
if field_type == "password" and field_val == "$encrypted$" and object_actual is not None:
|
||||||
attrs['notification_configuration'][field] = object_actual.notification_configuration[field]
|
attrs['notification_configuration'][field] = object_actual.notification_configuration[field]
|
||||||
|
if field == "http_method" and field_val.lower() not in ['put', 'post']:
|
||||||
|
error_list.append(_("HTTP method must be either 'POST' or 'PUT'."))
|
||||||
if missing_fields:
|
if missing_fields:
|
||||||
error_list.append(_("Missing required fields for Notification Configuration: {}.").format(missing_fields))
|
error_list.append(_("Missing required fields for Notification Configuration: {}.").format(missing_fields))
|
||||||
if incorrect_type_fields:
|
if incorrect_type_fields:
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class WebhookBackend(AWXBaseEmailBackend):
|
|||||||
sent_messages = 0
|
sent_messages = 0
|
||||||
if 'User-Agent' not in self.headers:
|
if 'User-Agent' not in self.headers:
|
||||||
self.headers['User-Agent'] = "Tower {}".format(get_awx_version())
|
self.headers['User-Agent'] = "Tower {}".format(get_awx_version())
|
||||||
if self.http_method.lower() not in ('put', 'post'):
|
if self.http_method.lower() not in ['put','post']:
|
||||||
raise ValueError("HTTP method must be either 'POST' or 'PUT'.")
|
raise ValueError("HTTP method must be either 'POST' or 'PUT'.")
|
||||||
chosen_method = getattr(requests, self.http_method.lower(), None)
|
chosen_method = getattr(requests, self.http_method.lower(), None)
|
||||||
for m in messages:
|
for m in messages:
|
||||||
|
|||||||
Reference in New Issue
Block a user