mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-16 23:38:36 +00:00
perf: swagger auth required
This commit is contained in:
@@ -91,7 +91,7 @@ cache_kwargs = {
|
||||
}
|
||||
# docs 路由
|
||||
urlpatterns += [
|
||||
path('api/swagger.<format>', views.get_swagger_view(False).without_ui(**cache_kwargs), name='schema-json'),
|
||||
path('api/swagger.<format>', views.get_swagger_view().without_ui(**cache_kwargs), name='schema-json'),
|
||||
re_path('api/docs/?', views.get_swagger_view().with_ui('swagger', **cache_kwargs), name="docs"),
|
||||
re_path('api/redoc/?', views.get_swagger_view().with_ui('redoc', **cache_kwargs), name='redoc'),
|
||||
]
|
||||
|
@@ -1,3 +1,5 @@
|
||||
import os
|
||||
|
||||
from drf_yasg import openapi
|
||||
from drf_yasg.generators import OpenAPISchemaGenerator
|
||||
from drf_yasg.inspectors import SwaggerAutoSchema
|
||||
@@ -149,13 +151,14 @@ api_info = openapi.Info(
|
||||
)
|
||||
|
||||
|
||||
def get_swagger_view(with_auth=True):
|
||||
def get_swagger_view():
|
||||
from ..urls import api_v1
|
||||
from django.urls import path, include
|
||||
patterns = [
|
||||
path('api/v1/', include(api_v1))
|
||||
]
|
||||
|
||||
with_auth = os.environ.get('DOC_AUTH', '1') == '1'
|
||||
if with_auth:
|
||||
permission_classes = (permissions.IsAuthenticated,)
|
||||
public = False
|
||||
|
Reference in New Issue
Block a user