Merge pull request #3745 from modoboa/fix/swagger_access

Disable authentication to access swagger UI
This commit is contained in:
Antoine Nguyen
2025-10-10 10:27:15 +02:00
committed by GitHub
4 changed files with 2 additions and 33 deletions
-26
View File
@@ -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",
},
)
@@ -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
-5
View File
@@ -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"),
+1 -1
View File
@@ -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