-
Notifications
You must be signed in to change notification settings - Fork 22
fix: 修复sdk网关接口问题 --story=130003551 #745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,7 @@ | |
| ) | ||
| from bkflow.interface.task.utils import StageConstantHandler, StageJobStateHandler | ||
| from bkflow.label.models import Label | ||
| from bkflow.permission.models import TASK_PERMISSION_TYPE, Token | ||
| from bkflow.permission.models import TASK_PERMISSION_TYPE, ResourceType, Token | ||
| from bkflow.space.configs import SuperusersConfig | ||
| from bkflow.space.models import SpaceConfig | ||
| from bkflow.space.permissions import SpaceSuperuserPermission | ||
|
|
@@ -155,17 +155,24 @@ def _inject_user_task_auth(request, data): | |
| resource_id=f"{task_detail['scope_type']}_{task_detail['scope_value']}", resource_type="SCOPE" | ||
| ) | Q(resource_id=task_detail["id"], resource_type="TASK") | ||
|
|
||
| # 只有当任务是MOCK调试任务时,可以TEMPLATE的MOCK权限条件 | ||
| if task_detail.get("create_method") == "MOCK": | ||
| base_query |= Q(resource_id=task_detail["template_id"], resource_type="TEMPLATE") | ||
| base_query |= Q(resource_id=task_detail["template_id"], resource_type="TEMPLATE") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| permissions = Token.objects.filter( | ||
| base_query, | ||
| space_id=task_detail["space_id"], | ||
| user=request.user.username, | ||
| expired_time__gte=timezone.now(), | ||
| ).values_list("permission_type", flat=True) | ||
| task_detail["auth"] = list(set(permissions)) | ||
| ).values_list("resource_type", "permission_type") | ||
|
|
||
| # 模板权限增加 FLOW_ 前缀,便于前端区分模板权限与任务/作用域权限 | ||
| auth_set = set() | ||
| for resource_type, permission_type in permissions: | ||
| if resource_type == ResourceType.TEMPLATE.value: | ||
| auth_set.add(f"FLOW_{permission_type}") | ||
| else: | ||
| auth_set.add(permission_type) | ||
|
|
||
| task_detail["auth"] = list(auth_set) | ||
|
|
||
| def get_space_id(self, request): | ||
| request_space_id = request.query_params.get("space_id", None) or request.data.get("space_id", None) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pipeline_tree为必选参数(必选: 是),但实际代码中CreateMockTaskWithTemplateIdSerializer并没有此字段,pipeline_tree 是由后端根据 template_id 自动获取的(优先草稿版本)。此处文档与代码实现不一致,建议移除该字段或标注为「由系统自动填充,无需传入」。