From 9d77c88d64ecb57cfe9aed178a207dd2fcb90d42 Mon Sep 17 00:00:00 2001 From: benero Date: Thu, 3 Oct 2024 11:23:34 +0800 Subject: [PATCH] minor: disable web browsable api --story=119850967 --- config/default.py | 1 + config/prod.py | 5 ----- iam/contrib/django/response.py | 3 ++- itsm/component/constants/iam.py | 3 +++ 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/default.py b/config/default.py index b530cbbe4..dbc40cdf7 100644 --- a/config/default.py +++ b/config/default.py @@ -349,6 +349,7 @@ def _(s): "rest_framework.parsers.FormParser", "rest_framework.parsers.MultiPartParser", ), + "DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",) } # ============================================================================== diff --git a/config/prod.py b/config/prod.py index 9178fd949..e169845d4 100644 --- a/config/prod.py +++ b/config/prod.py @@ -92,11 +92,6 @@ # CORS_ORIGIN_WHITELIST = CSRF_WHITELIST CORS_ORIGIN_ALLOW_ALL = True -# disable web browsable api in production -# http://masnun.com/2016/04/20/django-rest-framework-remember-to-disable-web-browsable-api-in-production.html -REST_FRAMEWORK.update( - {"DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",)} -) MEDIA_URL = "%smedia/" % SITE_URL CSRF_COOKIE_NAME = os.environ.get("BKAPP_CSRF_COOKIE_NAME", "bkitsm_csrftoken") diff --git a/iam/contrib/django/response.py b/iam/contrib/django/response.py index d80951562..2a870d9cf 100644 --- a/iam/contrib/django/response.py +++ b/iam/contrib/django/response.py @@ -12,6 +12,7 @@ """ from django.http.response import JsonResponse +from django.utils.translation import ugettext as _ from iam.contrib.http import HTTP_AUTH_FORBIDDEN_CODE @@ -21,7 +22,7 @@ def __init__(self, exc, *args, **kwargs): kwargs["data"] = { "result": False, "code": HTTP_AUTH_FORBIDDEN_CODE, - "message": "you have no permission to operate", + "message": _("您没有此操作的权限"), "data": None, "permission": exc.perms_apply_data(), } diff --git a/itsm/component/constants/iam.py b/itsm/component/constants/iam.py index 930dc3749..1b6d036a8 100644 --- a/itsm/component/constants/iam.py +++ b/itsm/component/constants/iam.py @@ -550,6 +550,9 @@ "ticket_state_view", "ticket_state_manage", "platform_manage_access", + "public_fields_manage", + "public_apis_manage", + "public_task_template_manage", ] IAM_SEARCH_INSTANCE_CACHE_TIME = 10 * 60 # 缓存5分钟