mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Merge branch 'develop' into develop-2.7
This commit is contained in:
@ -1,3 +1,15 @@
|
||||
# v2.6.7 (FUTURE)
|
||||
|
||||
## Enhancements
|
||||
|
||||
* [#3499](https://github.com/netbox-community/netbox/issues/3499) - Add `ca_file_path` to Webhook model to support user supplied CA certificate verification of webhook requests
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
# v2.6.6 (2019-10-10)
|
||||
|
||||
## Notes
|
||||
|
18
netbox/extras/migrations/0026_webhook_ca_file_path.py
Normal file
18
netbox/extras/migrations/0026_webhook_ca_file_path.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.2 on 2019-10-13 05:22
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('extras', '0025_objectchange_time_index'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='webhook',
|
||||
name='ca_file_path',
|
||||
field=models.CharField(blank=True, max_length=4096, null=True),
|
||||
),
|
||||
]
|
@ -84,6 +84,14 @@ class Webhook(models.Model):
|
||||
verbose_name='SSL verification',
|
||||
help_text="Enable SSL certificate verification. Disable with caution!"
|
||||
)
|
||||
ca_file_path = models.CharField(
|
||||
max_length=4096,
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name='CA File Path',
|
||||
help_text='The specific CA certificate file to use for SSL verification. '
|
||||
'Leave blank to use the system defaults.'
|
||||
)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('payload_url', 'type_create', 'type_update', 'type_delete',)
|
||||
@ -100,6 +108,11 @@ class Webhook(models.Model):
|
||||
"You must select at least one type: create, update, and/or delete."
|
||||
)
|
||||
|
||||
if not self.ssl_verification and self.ca_file_path:
|
||||
raise ValidationError({
|
||||
'ca_file_path': 'Do not specify a CA certificate file if SSL verification is dissabled.'
|
||||
})
|
||||
|
||||
|
||||
#
|
||||
# Custom fields
|
||||
|
@ -49,6 +49,8 @@ def process_webhook(webhook, data, model_name, event, timestamp, username, reque
|
||||
|
||||
with requests.Session() as session:
|
||||
session.verify = webhook.ssl_verification
|
||||
if webhook.ca_file_path:
|
||||
session.verify = webhook.ca_file_path
|
||||
response = session.send(prepared_request)
|
||||
|
||||
if response.status_code >= 200 and response.status_code <= 299:
|
||||
|
Reference in New Issue
Block a user