Browse Source

Closes #23861: Restrict allowed data source backends (#23862)

Add the ALLOWED_DATA_BACKENDS configuration parameter, which limits the
data source backends users can select and sync. All registered backends
remain available when it is unset; an empty list disables data sources.
Jeremy Stretch 1 ngày trước cách đây
mục cha
commit
0f464ec131

+ 15 - 0
docs/configuration/security.md

@@ -1,5 +1,20 @@
 # Security & Authentication Parameters
 
+## ALLOWED_DATA_BACKENDS
+
+!!! info "This parameter was introduced in NetBox v4.8."
+
+Default: `None`
+
+A list of the [data source](../models/core/datasource.md) backends available to users, identified by name (e.g. `['local', 'git']`). The names of the built-in backends are `local`, `git`, and `amazon-s3`; plugins may register others. If not defined, all registered backends are available. Set an empty list to disable data sources entirely.
+
+Only allowed backends can be selected when creating a data source or changing its type, and only data sources using an allowed backend can be synchronized. Existing data sources whose backend isn't allowed remain in place and can still be edited (e.g. to disable them) or deleted, but scheduled synchronizations of these sources are skipped.
+
+!!! note
+    The REST API schema lists all registered backends. Creating a source with, or changing a source to, a disallowed backend is rejected. Existing sources can retain their type when edited.
+
+---
+
 ## ALLOWED_URL_SCHEMES
 
 !!! tip "Dynamic Configuration Parameter"

+ 2 - 0
docs/models/core/datasource.md

@@ -16,6 +16,8 @@ The type of data source. Supported options include:
 * git repository
 * Amazon S3 bucket
 
+Administrators can restrict the types available using the [`ALLOWED_DATA_BACKENDS`](../../configuration/security.md#allowed_data_backends) configuration parameter.
+
 ### URL
 
 The URL identifying the remote source. Some examples are included below.

+ 1 - 1
docs/plugins/development/data-backends.md

@@ -1,6 +1,6 @@
 # Data Backends
 
-[Data sources](../../models/core/datasource.md) can be defined to reference data which exists on systems of record outside NetBox, such as a git repository or Amazon S3 bucket. Plugins can register their own backend classes to introduce support for additional resource types. This is done by subclassing NetBox's `DataBackend` class.
+[Data sources](../../models/core/datasource.md) can be defined to reference data which exists on systems of record outside NetBox, such as a git repository or Amazon S3 bucket. Plugins can register their own backend classes to introduce support for additional resource types. This is done by subclassing NetBox's `DataBackend` class. Administrators can restrict which backends are available using the [`ALLOWED_DATA_BACKENDS`](../../configuration/security.md#allowed_data_backends) configuration parameter, which references backends by their `name`.
 
 ```python title="data_backends.py"
 from netbox.data_backends import DataBackend

+ 3 - 1
netbox/core/api/views.py

@@ -8,7 +8,7 @@ from drf_spectacular.types import OpenApiTypes
 from drf_spectacular.utils import OpenApiParameter, extend_schema
 from rest_framework import viewsets
 from rest_framework.decorators import action
-from rest_framework.exceptions import PermissionDenied
+from rest_framework.exceptions import PermissionDenied, ValidationError
 from rest_framework.response import Response
 from rest_framework.routers import APIRootView
 from rq.job import Job as RQ_Job
@@ -56,6 +56,8 @@ class DataSourceViewSet(NetBoxModelViewSet):
 
         if not request.user.has_perm('core.sync_datasource', obj=datasource):
             raise PermissionDenied(_("This user does not have permission to synchronize this data source."))
+        if not datasource.backend_allowed:
+            raise ValidationError(_("The {type} backend is not enabled.").format(type=datasource.type))
 
         # Enqueue the sync job
         SyncDataSourceJob.enqueue(instance=datasource, user=request.user)

+ 2 - 2
netbox/core/forms/bulk_edit.py

@@ -3,7 +3,7 @@ from django.utils.translation import gettext_lazy as _
 
 from core.choices import JobIntervalChoices
 from core.models import *
-from netbox.data_backends import get_data_backend_choices
+from netbox.data_backends import get_allowed_data_backend_choices
 from netbox.forms import PrimaryModelBulkEditForm
 from utilities.forms.fields import ChoiceField
 from utilities.forms.rendering import FieldSet
@@ -17,7 +17,7 @@ __all__ = (
 class DataSourceBulkEditForm(PrimaryModelBulkEditForm):
     type = ChoiceField(
         label=_('Type'),
-        choices=get_data_backend_choices,
+        choices=get_allowed_data_backend_choices,
         required=False
     )
     enabled = forms.NullBooleanField(

+ 8 - 2
netbox/core/forms/model_forms.py

@@ -9,7 +9,7 @@ from django.utils.translation import gettext_lazy as _
 from core.forms.mixins import SyncedDataMixin
 from core.models import *
 from netbox.config import PARAMS, get_config
-from netbox.data_backends import get_data_backend_choices
+from netbox.data_backends import get_allowed_data_backend_choices
 from netbox.forms import NetBoxModelForm, PrimaryModelForm
 from netbox.registry import registry
 from utilities.forms import get_field_value
@@ -28,7 +28,7 @@ EMPTY_VALUES = ('', None, [], ())
 
 class DataSourceForm(PrimaryModelForm):
     type = ChoiceField(
-        choices=get_data_backend_choices,
+        choices=get_allowed_data_backend_choices,
         # No hx_target_id: changing type adds/removes the Backend Parameters fieldset entirely.
         widget=HTMXSelect()
     )
@@ -66,6 +66,12 @@ class DataSourceForm(PrimaryModelForm):
 
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
+
+        # Keep an existing source's type selectable even if its backend is no longer allowed
+        if self.instance.pk and not self.instance.backend_allowed:
+            if backend := registry['data_backends'].get(self.instance.type):
+                self.fields['type'].choices = [*self.fields['type'].choices, (self.instance.type, backend.label)]
+
         # Determine the selected backend type
         backend_type = get_field_value(self, 'type')
         backend = registry['data_backends'].get(backend_type)

+ 13 - 1
netbox/core/jobs.py

@@ -36,7 +36,7 @@ class SyncDataSourceJob(JobRunner):
         job = super().enqueue(*args, **kwargs)
 
         # Update the DataSource's synchronization status to queued
-        if datasource := job.object:
+        if (datasource := job.object) and datasource.backend_allowed:
             datasource.status = DataSourceStatusChoices.QUEUED
             DataSource.objects.filter(pk=datasource.pk).update(status=datasource.status)
 
@@ -46,6 +46,18 @@ class SyncDataSourceJob(JobRunner):
         datasource = DataSource.objects.get(pk=self.job.object_id)
         self.logger.debug(f"Found DataSource ID {datasource.pk}")
 
+        # Skip (rather than fail) syncs while the backend is disallowed, clearing any queued status set before then
+        if not datasource.backend_allowed:
+            self.logger.warning(
+                f"Skipping sync of data source {datasource}; the {datasource.type} backend is not enabled"
+            )
+            if datasource.status == DataSourceStatusChoices.QUEUED:
+                status = DataSourceStatusChoices.COMPLETED if datasource.last_synced else DataSourceStatusChoices.NEW
+                DataSource.objects.filter(pk=datasource.pk, status=DataSourceStatusChoices.QUEUED).update(
+                    status=status
+                )
+            return
+
         try:
             self.logger.info(f"Syncing data source {datasource}")
             datasource.sync()

+ 5 - 0
netbox/core/management/commands/syncdatasource.py

@@ -34,6 +34,11 @@ class Command(BaseCommand):
         for i, datasource in enumerate(datasources, start=1):
             self.stdout.write(f"[{i}] Syncing {datasource}... ", ending='')
             self.stdout.flush()
+            if not datasource.backend_allowed:
+                if not options['sync_all']:
+                    raise CommandError(f"Cannot sync {datasource}; the {datasource.type} backend is not enabled.")
+                self.stdout.write(f"Skipped ({datasource.type} backend is not enabled)")
+                continue
             try:
                 datasource.sync()
                 self.stdout.write(datasource.get_status_display())

+ 18 - 1
netbox/core/models/data.py

@@ -15,6 +15,7 @@ from django.utils import timezone
 from django.utils.translation import gettext_lazy as _
 
 from netbox.constants import ADVISORY_LOCK_KEYS, CENSOR_TOKEN, CENSOR_TOKEN_CHANGED
+from netbox.data_backends import data_backend_is_allowed
 from netbox.models import PrimaryModel
 from netbox.models.features import JobsMixin
 from netbox.registry import registry
@@ -151,9 +152,13 @@ class DataSource(JobsMixin, PrimaryModel):
             return self.revision[:7]
         return self.revision
 
+    @property
+    def backend_allowed(self):
+        return data_backend_is_allowed(self.type)
+
     @property
     def ready_for_sync(self):
-        return self.enabled and self.status not in (
+        return self.enabled and self.backend_allowed and self.status not in (
             DataSourceStatusChoices.QUEUED,
             DataSourceStatusChoices.SYNCING
         )
@@ -166,6 +171,11 @@ class DataSource(JobsMixin, PrimaryModel):
             raise ValidationError({
                 'type': _("Unknown backend type: {type}".format(type=self.type))
             })
+        # Allow edits that keep an existing source's disallowed backend
+        if self.type and not self.backend_allowed and self._type_changed():
+            raise ValidationError({
+                'type': _("The {type} backend is not enabled.").format(type=self.type)
+            })
 
         # Ensure URL scheme matches selected type
         if self.backend_class.is_local and self.url_scheme not in ('file', ''):
@@ -175,6 +185,11 @@ class DataSource(JobsMixin, PrimaryModel):
                 )
             })
 
+    def _type_changed(self):
+        if self._state.adding:
+            return True
+        return not DataSource.objects.filter(pk=self.pk, type=self.type).exists()
+
     def save(self, *args, **kwargs):
 
         # If recurring sync is disabled for an existing DataSource, clear any pending sync jobs for it and reset its
@@ -222,6 +237,8 @@ class DataSource(JobsMixin, PrimaryModel):
 
         using = router.db_for_write(self.__class__, instance=self)
 
+        if not self.backend_allowed:
+            raise SyncError(_("Cannot initiate sync; the {type} backend is not enabled.").format(type=self.type))
         if self.status == DataSourceStatusChoices.SYNCING:
             raise SyncError(_("Cannot initiate sync; syncing already in progress."))
 

+ 17 - 0
netbox/core/tests/test_api.py

@@ -136,6 +136,23 @@ class DataSourceTestCase(APIViewTestCases.APIViewTestCase):
         data_source = DataSource.objects.get(pk=response.data['id'])
         self.assertEqual(list(data_source.tags.values_list('slug', flat=True)), ['alpha'])
 
+    @override_settings(ALLOWED_DATA_BACKENDS=['local'])
+    def test_disallowed_backend(self):
+        """A data source can't be created or synced using a backend excluded by ALLOWED_DATA_BACKENDS."""
+        self.add_permissions('core.add_datasource', 'core.sync_datasource')
+        data_source = DataSource.objects.create(name='Data Source 7', type='git', source_url='https://example.com/git')
+
+        data = {'name': 'Data Source 8', 'type': 'git', 'source_url': 'https://example.com/git/source8'}
+        response = self.client.post(self._get_list_url(), data, format='json', **self.header)
+        self.assertHttpStatus(response, status.HTTP_400_BAD_REQUEST)
+        self.assertIn('type', response.data)
+
+        url = reverse('core-api:datasource-sync', kwargs={'pk': data_source.pk})
+        with patch('core.api.views.SyncDataSourceJob') as sync_job:
+            response = self.client.post(url, **self.header)
+        self.assertHttpStatus(response, status.HTTP_400_BAD_REQUEST)
+        sync_job.enqueue.assert_not_called()
+
     def test_update_tags(self):
         """Tags supplied on update replace the existing assignment."""
         data_source = DataSource.objects.first()

+ 24 - 1
netbox/core/tests/test_data_backends.py

@@ -4,10 +4,11 @@ from pathlib import Path
 from unittest import skipIf
 from unittest.mock import patch
 
-from django.test import TestCase
+from django.test import TestCase, override_settings
 
 from core.data_backends import S3Backend, url_has_embedded_credentials
 from core.exceptions import SyncError
+from netbox.data_backends import data_backend_is_allowed, get_allowed_data_backend_choices, get_data_backend_choices
 
 try:
     import dulwich  # noqa: F401
@@ -16,6 +17,28 @@ except ImportError:
     DULWICH_AVAILABLE = False
 
 
+class AllowedDataBackendsTestCase(TestCase):
+
+    def test_all_backends_allowed_by_default(self):
+        for name in ('local', 'git', 'amazon-s3'):
+            self.assertTrue(data_backend_is_allowed(name))
+        self.assertEqual(get_allowed_data_backend_choices(), get_data_backend_choices())
+
+    @override_settings(ALLOWED_DATA_BACKENDS=['local'])
+    def test_only_listed_backends_allowed(self):
+        self.assertTrue(data_backend_is_allowed('local'))
+        self.assertFalse(data_backend_is_allowed('git'))
+        self.assertEqual([choice[0] for choice in get_allowed_data_backend_choices()], [None, 'local'])
+
+        # Unfiltered choices still include every registered backend
+        self.assertIn('git', [choice[0] for choice in get_data_backend_choices()])
+
+    @override_settings(ALLOWED_DATA_BACKENDS=[])
+    def test_empty_list_allows_no_backends(self):
+        self.assertFalse(data_backend_is_allowed('local'))
+        self.assertEqual([choice[0] for choice in get_allowed_data_backend_choices()], [None])
+
+
 class URLEmbeddedCredentialsTestCase(TestCase):
     def test_url_with_embedded_username(self):
         self.assertTrue(url_has_embedded_credentials('https://myuser@bitbucket.org/workspace/repo.git'))

+ 34 - 0
netbox/core/tests/test_jobs.py

@@ -147,6 +147,40 @@ class SyncDataSourceJobTestCase(TestCase):
         self.assertEqual(self.datasource.status, DataSourceStatusChoices.FAILED)
         cache.assert_not_called()
 
+    @override_settings(ALLOWED_DATA_BACKENDS=[])
+    def test_disallowed_backend_skips_sync(self):
+        """A sync job for a data source whose backend isn't allowed neither syncs nor changes its status."""
+        job = MagicMock()
+        job.object = self.datasource
+        with patch('core.models.Job.enqueue', return_value=job):
+            SyncDataSourceJob.enqueue(instance=self.datasource)
+        self.datasource.refresh_from_db()
+        self.assertEqual(self.datasource.status, DataSourceStatusChoices.NEW)
+
+        runner = _make_runner(SyncDataSourceJob, object_id=self.datasource.pk)
+        with patch('core.models.DataSource.sync') as sync:
+            runner.run()
+        sync.assert_not_called()
+        self.datasource.refresh_from_db()
+        self.assertEqual(self.datasource.status, DataSourceStatusChoices.NEW)
+
+    def test_skipped_sync_clears_queued_status(self):
+        """Skipping a sync queued before its backend was disallowed leaves the data source ready to sync again."""
+        job = MagicMock()
+        job.object = self.datasource
+        with patch('core.models.Job.enqueue', return_value=job):
+            SyncDataSourceJob.enqueue(instance=self.datasource)
+        self.datasource.refresh_from_db()
+        self.assertEqual(self.datasource.status, DataSourceStatusChoices.QUEUED)
+
+        runner = _make_runner(SyncDataSourceJob, object_id=self.datasource.pk)
+        with override_settings(ALLOWED_DATA_BACKENDS=[]), patch('core.models.DataSource.sync') as sync:
+            runner.run()
+        sync.assert_not_called()
+        self.datasource.refresh_from_db()
+        self.assertEqual(self.datasource.status, DataSourceStatusChoices.NEW)
+        self.assertTrue(self.datasource.ready_for_sync)
+
     def test_run_raises_when_datasource_no_longer_exists(self):
         # If the DataSource was deleted between enqueue and run, the initial lookup
         # raises DoesNotExist; the framework will surface it as a job error.

+ 30 - 0
netbox/core/tests/test_management_commands.py

@@ -215,6 +215,8 @@ class SyncDataSourceTestCase(TestCase):
         def __init__(self, name):
             self.name = name
             self.pk = name
+            self.type = 'local'
+            self.backend_allowed = True
             self.sync = MagicMock()
 
         def __str__(self):
@@ -259,6 +261,34 @@ class SyncDataSourceTestCase(TestCase):
         self.assertIn('Syncing Test Data Source', out.getvalue())
         self.assertIn('completed', out.getvalue())
 
+    def test_all_skips_disallowed_datasource(self):
+        allowed = MagicMock(backend_allowed=True)
+        allowed.__str__.return_value = 'source-a'
+        allowed.get_status_display.return_value = 'completed'
+        disallowed = MagicMock(backend_allowed=False, type='git')
+        disallowed.__str__.return_value = 'source-b'
+        out = StringIO()
+
+        with patch('core.management.commands.syncdatasource.DataSource') as data_source_model:
+            data_source_model.objects.all.return_value = [allowed, disallowed]
+            call_command('syncdatasource', sync_all=True, stdout=out)
+
+        allowed.sync.assert_called_once_with()
+        disallowed.sync.assert_not_called()
+        self.assertIn('Skipped (git backend is not enabled)', out.getvalue())
+
+    def test_named_disallowed_datasource_raises_error(self):
+        datasource = self.FakeDataSource('source-a')
+        datasource.backend_allowed = False
+
+        with patch('core.management.commands.syncdatasource.DataSource') as data_source_model:
+            data_source_model.objects.filter.return_value = self.FakeQuerySet([datasource])
+            with self.assertRaisesMessage(CommandError, 'the local backend is not enabled'):
+                call_command('syncdatasource', 'source-a', stdout=StringIO())
+
+        datasource.sync.assert_not_called()
+        data_source_model.objects.filter.assert_called_once()  # Name lookup only; no FAILED status update
+
     def test_named_datasource_syncs_matching_datasource(self):
         datasource = self.FakeDataSource('source-a')
         datasources = self.FakeQuerySet([datasource])

+ 30 - 1
netbox/core/tests/test_models.py

@@ -8,7 +8,7 @@ from unittest.mock import MagicMock, patch
 
 from django.contrib.auth.models import AnonymousUser
 from django.contrib.contenttypes.models import ContentType
-from django.core.exceptions import ObjectDoesNotExist
+from django.core.exceptions import ObjectDoesNotExist, ValidationError
 from django.core.management import call_command
 from django.db import IntegrityError, connection
 from django.db.models.signals import pre_save
@@ -397,6 +397,35 @@ class DataSourceTestCase(TestCase):
             {'a.txt': b'new\n', 'b.txt': b'new\n', 'legacy.py': b'root\n', nested_path: b'nested\n'},
         )
 
+    @override_settings(ALLOWED_DATA_BACKENDS=['local'])
+    def test_clean_rejects_disallowed_backend(self):
+        """A data source can't be created with, or changed to, a backend excluded by ALLOWED_DATA_BACKENDS."""
+        new_datasource = DataSource(name='Data Source 3', type='git', source_url='https://example.invalid/repo.git')
+        with self.assertRaises(ValidationError) as cm:
+            new_datasource.full_clean()
+        self.assertIn('type', cm.exception.message_dict)
+
+        self.datasource.type = 'git'
+        self.datasource.source_url = 'https://example.invalid/repo.git'
+        with self.assertRaises(ValidationError) as cm:
+            self.datasource.full_clean()
+        self.assertIn('type', cm.exception.message_dict)
+
+    @override_settings(ALLOWED_DATA_BACKENDS=[])
+    def test_clean_permits_editing_source_with_disallowed_backend(self):
+        """An existing data source can still be edited after its backend is excluded by ALLOWED_DATA_BACKENDS."""
+        self.datasource.enabled = False
+        self.datasource.full_clean()
+
+    @override_settings(ALLOWED_DATA_BACKENDS=[])
+    def test_sync_rejects_disallowed_backend(self):
+        """A data source with a backend excluded by ALLOWED_DATA_BACKENDS can't be synced."""
+        self.assertFalse(self.datasource.ready_for_sync)
+        with self.assertRaisesMessage(SyncError, 'backend is not enabled'):
+            self.datasource.sync()
+        self.assert_files_unchanged()
+        self.assertEqual(self.datasource.status, DataSourceStatusChoices.COMPLETED)
+
 
 class ObjectTypeTestCase(TestCase):
 

+ 37 - 0
netbox/core/tests/test_views.py

@@ -6,6 +6,7 @@ from unittest.mock import patch
 
 from django.contrib.contenttypes.models import ContentType
 from django.db import connection, transaction
+from django.test import override_settings
 from django.test.utils import CaptureQueriesContext
 from django.urls import reverse
 from django.utils import timezone
@@ -126,6 +127,42 @@ class DataSourceTestCase(ViewTestCases.PrimaryObjectViewTestCase):
                 response, f'formaction="{url}?return_url={list_url}" formmethod="post" data-disable-on-submit>'
             )
 
+    @override_settings(ALLOWED_DATA_BACKENDS=['git'])
+    def test_disallowed_backend(self):
+        """Only allowed backends are offered, and a source with a disallowed backend can't be synced."""
+        self.add_permissions('core.add_datasource', 'core.view_datasource', 'core.sync_datasource')
+        datasource = DataSource.objects.first()
+        sync_url = reverse('core:datasource_sync', kwargs={'pk': datasource.pk})
+
+        response = self.client.get(reverse('core:datasource_add'))
+        self.assertContains(response, '<option value="git"')
+        self.assertNotContains(response, '<option value="local"')
+
+        response = self.client.get(datasource.get_absolute_url())
+        self.assertHttpStatus(response, 200)
+        self.assertNotContains(response, sync_url)
+
+        with patch('core.views.SyncDataSourceJob') as sync_job:
+            response = self.client.post(sync_url)
+        self.assertHttpStatus(response, 302)
+        sync_job.enqueue.assert_not_called()
+
+    @override_settings(ALLOWED_DATA_BACKENDS=[])
+    def test_edit_source_with_disallowed_backend(self):
+        """An existing data source whose backend isn't allowed can still be edited."""
+        self.add_permissions('core.change_datasource')
+        datasource = DataSource.objects.first()
+
+        response = self.client.post(reverse('core:datasource_edit', kwargs={'pk': datasource.pk}), {
+            'name': datasource.name,
+            'type': datasource.type,
+            'source_url': datasource.source_url,
+        })
+
+        self.assertHttpStatus(response, 302)
+        datasource.refresh_from_db()
+        self.assertFalse(datasource.enabled)
+
 
 class DataFileTestCase(
     ViewTestCases.GetObjectViewTestCase,

+ 9 - 0
netbox/core/views.py

@@ -132,6 +132,15 @@ class DataSourceSyncView(GetReturnURLMixin, BaseObjectView):
 
     def post(self, request, pk):
         datasource = get_object_or_404(self.queryset, pk=pk)
+        if not datasource.backend_allowed:
+            messages.error(
+                request,
+                _("Cannot sync {datasource}; the {type} backend is not enabled.").format(
+                    datasource=datasource, type=datasource.type
+                )
+            )
+            return redirect(self.get_return_url(request, datasource))
+
         # Enqueue the sync job
         job = SyncDataSourceJob.enqueue(instance=datasource, user=request.user)
         messages.success(

+ 25 - 0
netbox/netbox/data_backends.py

@@ -1,11 +1,15 @@
 from contextlib import contextmanager
 from urllib.parse import urlparse
 
+from django.conf import settings
+
 from netbox.registry import registry
 from utilities.choices import Choice
 
 __all__ = (
     'DataBackend',
+    'data_backend_is_allowed',
+    'get_allowed_data_backend_choices',
     'get_data_backend_choices',
     'register_data_backend',
 )
@@ -81,6 +85,27 @@ def get_data_backend_choices():
     ]
 
 
+def get_allowed_data_backend_choices():
+    """
+    Return choices for only those registered backends permitted by ALLOWED_DATA_BACKENDS.
+    """
+    return [
+        (None, '---------'),
+        *[
+            Choice(name, cls.label) for name, cls in registry['data_backends'].items()
+            if data_backend_is_allowed(name)
+        ]
+    ]
+
+
+def data_backend_is_allowed(name):
+    """
+    Return True if the named backend is permitted by ALLOWED_DATA_BACKENDS (all backends are permitted if unset).
+    """
+    allowed = settings.ALLOWED_DATA_BACKENDS
+    return allowed is None or name in allowed
+
+
 def register_data_backend():
     """
     Decorator for registering a DataBackend class.

+ 1 - 0
netbox/netbox/settings.py

@@ -89,6 +89,7 @@ elif hasattr(configuration, 'DATABASE') and hasattr(configuration, 'DATABASES'):
 # Set static config parameters
 param = partial(get_param, configuration)
 ADMINS = param('ADMINS', [], types=(list, tuple))
+ALLOWED_DATA_BACKENDS = param('ALLOWED_DATA_BACKENDS', None, types=(list, tuple), allow_none=True)
 ALLOWED_HOSTS = param('ALLOWED_HOSTS', types=(list, tuple))  # Required
 API_TOKEN_PEPPERS = param('API_TOKEN_PEPPERS', {}, types=dict)
 AUTH_PASSWORD_VALIDATORS = param('AUTH_PASSWORD_VALIDATORS', [