Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Optional
* ``NUM_PROXIES``: the number of reverse proxies in front of the application, as an integer. This is used to determine the actual client IP adres. On Kubernetes with an ingress you typically want to set this to 2. Defaults to: ``1``.
* ``CSRF_TRUSTED_ORIGINS``: A list of trusted origins for unsafe requests (e.g. POST). Defaults to: ``[]``.
* ``NOTIFICATIONS_DISABLED``: indicates whether or not notifications should be sent to the Notificaties API for operations on the API endpoints. Defaults to ``True`` for the ``dev`` environment, otherwise defaults to ``False``.
* ``SITE_DOMAIN``: Defines the primary domain where the application is hosted. Defaults to: ``(empty string)``.
* ``SENTRY_DSN``: URL of the sentry project to send error reports to. Default empty, i.e. -> no monitoring set up. Highly recommended to configure this.
* ``DISABLE_2FA``: Whether or not two factor authentication should be disabled. Defaults to: ``False``.
* ``LOG_OUTGOING_REQUESTS_EMIT_BODY``: Whether or not outgoing request bodies should be logged. Defaults to: ``True``.
Expand Down
6 changes: 3 additions & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ click-plugins==1.1.1
# via celery
click-repl==0.3.0
# via celery
commonground-api-common==2.5.2
commonground-api-common==2.5.5
# via open-api-framework
coreapi==2.3.3
# via commonground-api-common
Expand Down Expand Up @@ -244,11 +244,11 @@ mozilla-django-oidc-db==0.22.0
# via
# -r requirements/base.in
# open-api-framework
notifications-api-common==0.6.0
notifications-api-common==0.7.2
# via
# -r requirements/base.in
# commonground-api-common
open-api-framework==0.9.3
open-api-framework==0.9.6
# via -r requirements/base.in
orderedmultidict==1.0.1
# via furl
Expand Down
6 changes: 3 additions & 3 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ click-repl==0.3.0
# celery
codecov==2.1.13
# via -r requirements/test-tools.in
commonground-api-common==2.5.2
commonground-api-common==2.5.5
# via
# -c requirements/base.txt
# -r requirements/base.txt
Expand Down Expand Up @@ -484,12 +484,12 @@ multidict==6.0.5
# via yarl
mypy-extensions==1.0.0
# via black
notifications-api-common==0.6.0
notifications-api-common==0.7.2
# via
# -c requirements/base.txt
# -r requirements/base.txt
# commonground-api-common
open-api-framework==0.9.3
open-api-framework==0.9.6
# via
# -c requirements/base.txt
# -r requirements/base.txt
Expand Down
6 changes: 3 additions & 3 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ codecov==2.1.13
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
commonground-api-common==2.5.2
commonground-api-common==2.5.5
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
Expand Down Expand Up @@ -573,12 +573,12 @@ mypy-extensions==1.0.0
# -c requirements/ci.txt
# -r requirements/ci.txt
# black
notifications-api-common==0.6.0
notifications-api-common==0.7.2
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# commonground-api-common
open-api-framework==0.9.3
open-api-framework==0.9.6
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
Expand Down
2 changes: 2 additions & 0 deletions src/objects/conf/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,5 @@
}

UNAUTHORIZED_FIELDS_HEADER = "X-Unauthorized-Fields"

COMMONGROUND_API_COMMON_GET_DOMAIN = "objects.utils.get_domain"
7 changes: 6 additions & 1 deletion src/objects/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
INSTALLED_APPS = INSTALLED_APPS + [
# Optional applications.
"django.contrib.gis",
# `django.contrib.sites` added at the project level because it has been removed at the packages level.
# This component is deprecated and should be completely removed.
# To determine the project's domain, use the `SITE_DOMAIN` environment variable.
"django.contrib.sites",
# External applications.
"rest_framework_gis",
# Project applications.
Expand All @@ -22,7 +26,6 @@
"objects.utils",
]


# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/

Expand Down Expand Up @@ -89,3 +92,5 @@
"objects.setup_configuration.steps.objecttypes.ObjectTypesConfigurationStep",
"objects.setup_configuration.steps.token_auth.TokenAuthConfigurationStep",
)

NOTIFICATIONS_API_GET_DOMAIN = "objects.utils.get_domain"
7 changes: 1 addition & 6 deletions src/objects/tests/v2/test_notifications_kanaal.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from io import StringIO

from django.contrib.sites.models import Site
from django.core.management import call_command
from django.test import override_settings

Expand All @@ -17,15 +16,11 @@
NOTIFICATIONS_API_ROOT = "https://notificaties-api.vng.cloud/api/v1/"


@override_settings(IS_HTTPS=True)
@override_settings(IS_HTTPS=True, SITE_DOMAIN="example.com")
class CreateNotifKanaalTestCase(APITestCase):
@classmethod
def setUpTestData(cls):
super().setUpTestData()
site = Site.objects.get_current()
site.domain = "example.com"
site.save()

kanaal = ObjectKanaal(label="kanaal_test", main_resource=Object)
cls.addClassCleanup(lambda: KANAAL_REGISTRY.remove(kanaal))

Expand Down
11 changes: 9 additions & 2 deletions src/objects/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

from django.conf import settings
from django.http import HttpRequest

Expand All @@ -10,9 +12,14 @@ def get_domain() -> str:
"""
from django.contrib.sites.models import Site

if settings.OBJECTS_DOMAIN:
return settings.OBJECTS_DOMAIN
if settings.SITE_DOMAIN:
return settings.SITE_DOMAIN

warnings.warn(
"Deriving the domain from the `Sites` configuration will soon be deprecated, "
"please migrate to the SITE_DOMAIN setting.",
PendingDeprecationWarning,
)
return Site.objects.get_current().domain


Expand Down