From d3cd1f2c1a5ff9e2d12a2daace5cfeca2e66bad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E4=BF=8A=E7=94=B7?= Date: Thu, 18 Dec 2025 17:58:55 +0800 Subject: [PATCH] feat(apikey system): the default resource_id for creating the service's apikey is workspace_id --- api/app/controllers/api_key_controller.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/app/controllers/api_key_controller.py b/api/app/controllers/api_key_controller.py index 7617915b..dce8450d 100644 --- a/api/app/controllers/api_key_controller.py +++ b/api/app/controllers/api_key_controller.py @@ -8,6 +8,7 @@ from sqlalchemy.orm import Session from app.core.error_codes import BizCode from app.db import get_db from app.dependencies import get_current_user, cur_workspace_access_guard +from app.models import ApiKeyType from app.models.user_model import User from app.core.response_utils import success from app.schemas import api_key_schema @@ -39,6 +40,8 @@ def create_api_key( """ try: workspace_id = current_user.current_workspace_id + if data.type == ApiKeyType.SERVICE.value and not data.resource_id: + data.resource_id = workspace_id # 创建 API Key api_key_obj = ApiKeyService.create_api_key(