From 7c60e9e3e3dc400afdd383f1c768144d94a3ede0 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Fri, 31 Jul 2026 11:31:36 +0800 Subject: [PATCH] fix: add FILE_AUTH configuration for enhanced file access control --- apps/maxkb/conf.py | 3 ++- apps/oss/serializers/file.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/maxkb/conf.py b/apps/maxkb/conf.py index 3f747418e8d..16c8f6bc679 100644 --- a/apps/maxkb/conf.py +++ b/apps/maxkb/conf.py @@ -47,6 +47,7 @@ class Config(dict): "REDIS_MAX_CONNECTIONS": 100, # 外置语言包路径 "EXTERNAL_LOCALE_PATH": "/opt/maxkb/local/locales", + "FILE_AUTH": True } def get_debug(self) -> bool: @@ -167,7 +168,7 @@ def from_mapping(self, *mapping, **kwargs): """Updates the config like :meth:`update` ignoring items with non-upper keys. - .. versionadded:: 0.11 + ... versionadded:: 0.11 """ mappings = [] if len(mapping) == 1: diff --git a/apps/oss/serializers/file.py b/apps/oss/serializers/file.py index 2f14b67325f..ab87e9d64ed 100644 --- a/apps/oss/serializers/file.py +++ b/apps/oss/serializers/file.py @@ -17,6 +17,7 @@ from homepage.serializers.homepage import is_workspace_manage, is_extends_workspace_manage, \ has_extends_workspace_manage_permission, hasPermission from knowledge.models import File, FileSourceType, Document, Knowledge, PublicFileAccess +from maxkb.const import CONFIG from system_manage.models import WorkspaceUserResourcePermission from system_manage.models.resource_mapping import ResourceMapping, ResourceType from tools.serializers.tool import UploadedFileField @@ -82,6 +83,8 @@ def _deny(): def auth(file, mk_file_auth): + if not CONFIG.get("FILE_AUTH", True): + return # 公共/临时文件无需鉴权 if file.source_type in _PUBLIC_SOURCE_TYPES: return