mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
implemented #3445 - Add support for additional user defined headers to be added to webhook requests
This commit is contained in:
@@ -70,6 +70,12 @@ class Webhook(models.Model):
|
||||
default=WEBHOOK_CT_JSON,
|
||||
verbose_name='HTTP content type'
|
||||
)
|
||||
additional_headers = JSONField(
|
||||
null=True,
|
||||
blank=True,
|
||||
help_text="User supplied headers which should be added to the request in addition to the HTTP content type. "
|
||||
"Headers are supplied as key/value pairs in a JSON object."
|
||||
)
|
||||
secret = models.CharField(
|
||||
max_length=255,
|
||||
blank=True,
|
||||
@@ -115,6 +121,12 @@ class Webhook(models.Model):
|
||||
'ca_file_path': 'Do not specify a CA certificate file if SSL verification is dissabled.'
|
||||
})
|
||||
|
||||
# Verify that JSON data is provided as an object
|
||||
if self.additional_headers and type(self.additional_headers) is not dict:
|
||||
raise ValidationError({
|
||||
'additional_headers': 'Header JSON data must be in object form. Example: {"X-API-KEY": "abc123"}'
|
||||
})
|
||||
|
||||
|
||||
#
|
||||
# Custom fields
|
||||
|
Reference in New Issue
Block a user