From f63aecbc32c1ddececa2283d48ae2afa54a9132c Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Thu, 9 Oct 2025 16:48:03 +0200 Subject: [PATCH 1/2] Disable authentication to access swagger UI --- modoboa/core/commands/templates/settings.py.tpl | 2 +- modoboa/urls.py | 5 ----- test_project/test_project/settings.py | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/modoboa/core/commands/templates/settings.py.tpl b/modoboa/core/commands/templates/settings.py.tpl index 4b21ab032..7ba925386 100644 --- a/modoboa/core/commands/templates/settings.py.tpl +++ b/modoboa/core/commands/templates/settings.py.tpl @@ -245,7 +245,7 @@ SPECTACULAR_SETTINGS = { 'SCHEMA_PATH_PREFIX': r'/api/v[0-9]', 'TITLE': 'Modoboa API', 'VERSION': None, - 'SERVE_PERMISSIONS': ['rest_framework.permissions.IsAuthenticated'], + 'SERVE_AUTHENTICATION': [], } # Modoboa settings diff --git a/modoboa/urls.py b/modoboa/urls.py index 91c5b739b..22788815c 100644 --- a/modoboa/urls.py +++ b/modoboa/urls.py @@ -52,11 +52,6 @@ urlpatterns += exts_pool.get_urls() # API urls urlpatterns += [ # FIXME: legacy, to remove ASAP - path( - "docs/openapi.json", - SpectacularJSONAPIView.as_view(api_version="v1"), - name="schema-v1-legacy", - ), path( "api/schema-v1/", SpectacularJSONAPIView.as_view(api_version="v1"), diff --git a/test_project/test_project/settings.py b/test_project/test_project/settings.py index 545f28f08..e6871d18c 100644 --- a/test_project/test_project/settings.py +++ b/test_project/test_project/settings.py @@ -261,7 +261,7 @@ SPECTACULAR_SETTINGS = { "SCHEMA_PATH_PREFIX": r"/api/v[0-9]", "TITLE": "Modoboa API", "VERSION": None, - "SERVE_PERMISSIONS": ["rest_framework.permissions.IsAuthenticated"], + "SERVE_AUTHENTICATION": [], } # Modoboa settings From 571fb838355686c157bc11520ed29d6ea4991d61 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Fri, 10 Oct 2025 09:12:29 +0200 Subject: [PATCH 2/2] Removed deprecated test --- modoboa/core/api/v1/tests.py | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 modoboa/core/api/v1/tests.py diff --git a/modoboa/core/api/v1/tests.py b/modoboa/core/api/v1/tests.py deleted file mode 100644 index d4b06a798..000000000 --- a/modoboa/core/api/v1/tests.py +++ /dev/null @@ -1,26 +0,0 @@ -from django.urls import reverse_lazy - -from modoboa.lib.tests import ModoAPITestCase - - -class OpenAPITestCase(ModoAPITestCase): - openapi_schema_url = reverse_lazy("schema-v1-legacy") - - def test_unauthorized(self): - self.client.logout() - - response = self.client.get(self.openapi_schema_url) - self.assertEqual(response.status_code, 401) - - def test_get_schema(self): - self.assertEqual(self.openapi_schema_url, "/docs/openapi.json") - - response = self.client.get(self.openapi_schema_url) - self.assertEqual(response.status_code, 200) - self.assertEqual( - response.json()["info"], - { - "title": "Modoboa API", - "version": "v1", - }, - )