prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  【安全】安全漏洞扫描，生产环境下能访问后台swagger
  **用文字描述你遇到的问题**
  
  生产环境，swagger未屏蔽可访问
  
  **重现方法**
  ![image](https://user-images.githubusercontent.com/49228807/221740484-96ab7d07-ba5c-44c6-bc2f-420f9de733ed.png)
  
  对应源码未屏蔽
  https://github.com/TencentBlueKing/bk-user/blob/40ee56ed90d47b214274819394aa21ec7459b970/src/api/bkuser_core/apis/urls.py#L45
  
  **预期行为**
  
  预期的正常行为
  
  **版本**
  - 2.5.2
  - 是否是企业版问题？
  是
  
  **如果是 SaaS 页面问题，请提供使用的操作系统和浏览器信息**
   - OS: [e.g. iOS]
   - Browser [e.g. chrome, safari]
   - Version [e.g. 22]
  
  **额外信息**
  
  任何你觉得有助于问题解决的内容
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/api/bkuser_core/apis/urls.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 """
  3 TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-用户管理(Bk-User) available.
  4 Copyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved.
  5 Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
  6 You may obtain a copy of the License at http://opensource.org/licenses/MIT
  7 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  8 an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  9 specific language governing permissions and limitations under the License.
  10 """
  11 from django.conf.urls import include, url
  12 from drf_yasg import openapi
  13 from drf_yasg.generators import OpenAPISchemaGenerator
  14 from drf_yasg.views import get_schema_view
  15 from rest_framework import permissions
  16 
  17 
  18 class CustomOpenAPISchemaGenerator(OpenAPISchemaGenerator):
  19     def get_schema(self, request=None, public=False):
  20         schema = super().get_schema(request, public)
  21         return schema
  22 
  23 
  24 schema_view = get_schema_view(
  25     openapi.Info(
  26         title="蓝鲸用户管理 API",
  27         default_version="v2",
  28         description="蓝鲸用户管理后台服务 API",
  29         license=openapi.License(name="MIT License"),
  30     ),
  31     public=True,
  32     permission_classes=(permissions.AllowAny,),
  33     generator_class=CustomOpenAPISchemaGenerator,
  34     patterns=[
  35         url(r"^", include("bkuser_core.monitoring.urls")),
  36         url(r"^", include("bkuser_core.departments.urls")),
  37         url(r"^", include("bkuser_core.profiles.urls")),
  38         url(r"^", include("bkuser_core.categories.urls")),
  39         # url(r"^", include("bkuser_core.user_settings.urls")),
  40         # url(r"^", include("bkuser_core.audit.urls")),
  41     ],
  42 )
  43 
  44 
  45 urlpatterns = [
  46     url(r"^swagger(?P<format>\.json|\.yaml)$", schema_view.without_ui(cache_timeout=0), name="schema-json"),
  47     url(r"^swagger/$", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"),
  48     url(r"^redoc/$", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"),
  49 ]
  50
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/api/bkuser_core/apis/urls.py b/src/api/bkuser_core/apis/urls.py
  --- a/src/api/bkuser_core/apis/urls.py
  +++ b/src/api/bkuser_core/apis/urls.py
  @@ -8,6 +8,7 @@
   an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
   specific language governing permissions and limitations under the License.
   """
  +from django.conf import settings
   from django.conf.urls import include, url
   from drf_yasg import openapi
   from drf_yasg.generators import OpenAPISchemaGenerator
  @@ -41,9 +42,10 @@
       ],
   )
   
  -
  -urlpatterns = [
  -    url(r"^swagger(?P<format>\.json|\.yaml)$", schema_view.without_ui(cache_timeout=0), name="schema-json"),
  -    url(r"^swagger/$", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"),
  -    url(r"^redoc/$", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"),
  -]
  +urlpatterns = []
  +if settings.DEBUG:
  +    urlpatterns += [
  +        url(r"^swagger(?P<format>\.json|\.yaml)$", schema_view.without_ui(cache_timeout=0), name="schema-json"),
  +        url(r"^swagger/$", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"),
  +        url(r"^redoc/$", schema_view.with_ui("redoc", cache_timeout=0), name="schema-redoc"),
  +    ]
  
verification_info: {"golden_diff": "diff --git a/src/api/bkuser_core/apis/urls.py b/src/api/bkuser_core/apis/urls.py\n--- a/src/api/bkuser_core/apis/urls.py\n+++ b/src/api/bkuser_core/apis/urls.py\n@@ -8,6 +8,7 @@\n an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the\n specific language governing permissions and limitations under the License.\n \"\"\"\n+from django.conf import settings\n from django.conf.urls import include, url\n from drf_yasg import openapi\n from drf_yasg.generators import OpenAPISchemaGenerator\n@@ -41,9 +42,10 @@\n     ],\n )\n \n-\n-urlpatterns = [\n-    url(r\"^swagger(?P<format>\\.json|\\.yaml)$\", schema_view.without_ui(cache_timeout=0), name=\"schema-json\"),\n-    url(r\"^swagger/$\", schema_view.with_ui(\"swagger\", cache_timeout=0), name=\"schema-swagger-ui\"),\n-    url(r\"^redoc/$\", schema_view.with_ui(\"redoc\", cache_timeout=0), name=\"schema-redoc\"),\n-]\n+urlpatterns = []\n+if settings.DEBUG:\n+    urlpatterns += [\n+        url(r\"^swagger(?P<format>\\.json|\\.yaml)$\", schema_view.without_ui(cache_timeout=0), name=\"schema-json\"),\n+        url(r\"^swagger/$\", schema_view.with_ui(\"swagger\", cache_timeout=0), name=\"schema-swagger-ui\"),\n+        url(r\"^redoc/$\", schema_view.with_ui(\"redoc\", cache_timeout=0), name=\"schema-redoc\"),\n+    ]\n", "issue": "\u3010\u5b89\u5168\u3011\u5b89\u5168\u6f0f\u6d1e\u626b\u63cf\uff0c\u751f\u4ea7\u73af\u5883\u4e0b\u80fd\u8bbf\u95ee\u540e\u53f0swagger\n**\u7528\u6587\u5b57\u63cf\u8ff0\u4f60\u9047\u5230\u7684\u95ee\u9898**\r\n\r\n\u751f\u4ea7\u73af\u5883\uff0cswagger\u672a\u5c4f\u853d\u53ef\u8bbf\u95ee\r\n\r\n**\u91cd\u73b0\u65b9\u6cd5**\r\n![image](https://user-images.githubusercontent.com/49228807/221740484-96ab7d07-ba5c-44c6-bc2f-420f9de733ed.png)\r\n\r\n\u5bf9\u5e94\u6e90\u7801\u672a\u5c4f\u853d\r\nhttps://github.com/TencentBlueKing/bk-user/blob/40ee56ed90d47b214274819394aa21ec7459b970/src/api/bkuser_core/apis/urls.py#L45\r\n\r\n**\u9884\u671f\u884c\u4e3a**\r\n\r\n\u9884\u671f\u7684\u6b63\u5e38\u884c\u4e3a\r\n\r\n**\u7248\u672c**\r\n- 2.5.2\r\n- \u662f\u5426\u662f\u4f01\u4e1a\u7248\u95ee\u9898\uff1f\r\n\u662f\r\n\r\n**\u5982\u679c\u662f SaaS \u9875\u9762\u95ee\u9898\uff0c\u8bf7\u63d0\u4f9b\u4f7f\u7528\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u6d4f\u89c8\u5668\u4fe1\u606f**\r\n - OS: [e.g. iOS]\r\n - Browser [e.g. chrome, safari]\r\n - Version [e.g. 22]\r\n\r\n**\u989d\u5916\u4fe1\u606f**\r\n\r\n\u4efb\u4f55\u4f60\u89c9\u5f97\u6709\u52a9\u4e8e\u95ee\u9898\u89e3\u51b3\u7684\u5185\u5bb9\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"\nTencentBlueKing is pleased to support the open source community by making \u84dd\u9cb8\u667a\u4e91-\u7528\u6237\u7ba1\u7406(Bk-User) available.\nCopyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved.\nLicensed under the MIT License (the \"License\"); you may not use this file except in compliance with the License.\nYou may obtain a copy of the License at http://opensource.org/licenses/MIT\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on\nan \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the\nspecific language governing permissions and limitations under the License.\n\"\"\"\nfrom django.conf.urls import include, url\nfrom drf_yasg import openapi\nfrom drf_yasg.generators import OpenAPISchemaGenerator\nfrom drf_yasg.views import get_schema_view\nfrom rest_framework import permissions\n\n\nclass CustomOpenAPISchemaGenerator(OpenAPISchemaGenerator):\n    def get_schema(self, request=None, public=False):\n        schema = super().get_schema(request, public)\n        return schema\n\n\nschema_view = get_schema_view(\n    openapi.Info(\n        title=\"\u84dd\u9cb8\u7528\u6237\u7ba1\u7406 API\",\n        default_version=\"v2\",\n        description=\"\u84dd\u9cb8\u7528\u6237\u7ba1\u7406\u540e\u53f0\u670d\u52a1 API\",\n        license=openapi.License(name=\"MIT License\"),\n    ),\n    public=True,\n    permission_classes=(permissions.AllowAny,),\n    generator_class=CustomOpenAPISchemaGenerator,\n    patterns=[\n        url(r\"^\", include(\"bkuser_core.monitoring.urls\")),\n        url(r\"^\", include(\"bkuser_core.departments.urls\")),\n        url(r\"^\", include(\"bkuser_core.profiles.urls\")),\n        url(r\"^\", include(\"bkuser_core.categories.urls\")),\n        # url(r\"^\", include(\"bkuser_core.user_settings.urls\")),\n        # url(r\"^\", include(\"bkuser_core.audit.urls\")),\n    ],\n)\n\n\nurlpatterns = [\n    url(r\"^swagger(?P<format>\\.json|\\.yaml)$\", schema_view.without_ui(cache_timeout=0), name=\"schema-json\"),\n    url(r\"^swagger/$\", schema_view.with_ui(\"swagger\", cache_timeout=0), name=\"schema-swagger-ui\"),\n    url(r\"^redoc/$\", schema_view.with_ui(\"redoc\", cache_timeout=0), name=\"schema-redoc\"),\n]\n", "path": "src/api/bkuser_core/apis/urls.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\"\"\"\nTencentBlueKing is pleased to support the open source community by making \u84dd\u9cb8\u667a\u4e91-\u7528\u6237\u7ba1\u7406(Bk-User) available.\nCopyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved.\nLicensed under the MIT License (the \"License\"); you may not use this file except in compliance with the License.\nYou may obtain a copy of the License at http://opensource.org/licenses/MIT\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on\nan \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the\nspecific language governing permissions and limitations under the License.\n\"\"\"\nfrom django.conf import settings\nfrom django.conf.urls import include, url\nfrom drf_yasg import openapi\nfrom drf_yasg.generators import OpenAPISchemaGenerator\nfrom drf_yasg.views import get_schema_view\nfrom rest_framework import permissions\n\n\nclass CustomOpenAPISchemaGenerator(OpenAPISchemaGenerator):\n    def get_schema(self, request=None, public=False):\n        schema = super().get_schema(request, public)\n        return schema\n\n\nschema_view = get_schema_view(\n    openapi.Info(\n        title=\"\u84dd\u9cb8\u7528\u6237\u7ba1\u7406 API\",\n        default_version=\"v2\",\n        description=\"\u84dd\u9cb8\u7528\u6237\u7ba1\u7406\u540e\u53f0\u670d\u52a1 API\",\n        license=openapi.License(name=\"MIT License\"),\n    ),\n    public=True,\n    permission_classes=(permissions.AllowAny,),\n    generator_class=CustomOpenAPISchemaGenerator,\n    patterns=[\n        url(r\"^\", include(\"bkuser_core.monitoring.urls\")),\n        url(r\"^\", include(\"bkuser_core.departments.urls\")),\n        url(r\"^\", include(\"bkuser_core.profiles.urls\")),\n        url(r\"^\", include(\"bkuser_core.categories.urls\")),\n        # url(r\"^\", include(\"bkuser_core.user_settings.urls\")),\n        # url(r\"^\", include(\"bkuser_core.audit.urls\")),\n    ],\n)\n\nurlpatterns = []\nif settings.DEBUG:\n    urlpatterns += [\n        url(r\"^swagger(?P<format>\\.json|\\.yaml)$\", schema_view.without_ui(cache_timeout=0), name=\"schema-json\"),\n        url(r\"^swagger/$\", schema_view.with_ui(\"swagger\", cache_timeout=0), name=\"schema-swagger-ui\"),\n        url(r\"^redoc/$\", schema_view.with_ui(\"redoc\", cache_timeout=0), name=\"schema-redoc\"),\n    ]\n", "path": "src/api/bkuser_core/apis/urls.py"}]}