fix(resources): align can_view with list_resources (workspace-wide)
list_resources 已放开成 workspace-wide,但 can_view 仍要求
visibility in {workspace, public} 或 admin,导致 A 的 private
资源出现在 B 的列表里、但 B 调 GET /{id}、POST /{id}/download-url
与 POST /{id}/jupyter-relative-path 全部 404。
can_view 改为恒真,访问边界全部交给 get_visible_resource 的
workspace_id + status=active SQL 限定;visibility 字段保留为
上传/绑定时的语义标签。delete_resource 仍按 owner/admin 校验
403,不受影响。补 4 个 unit test。
This commit is contained in:
@@ -148,15 +148,10 @@ def resource_payload(
|
||||
|
||||
|
||||
def can_view(resource: DataResources, context: RequestContext) -> bool:
|
||||
# 2026-08-11: 临时取消"用户间目录互相不可见"约束
|
||||
# 同一 workspace 内的成员现在可以查看彼此的 private 资源。
|
||||
# 还原: 取消下方注释,恢复 owner_user_id 检查。
|
||||
return (
|
||||
# resource.owner_user_id == context.user.user_id
|
||||
# or
|
||||
resource.visibility in {"workspace", "public"}
|
||||
or context.is_admin
|
||||
)
|
||||
# 2026-08-11: 同一 workspace 内成员可以查看彼此的资源(含 private);
|
||||
# 保留 visibility 字段仅作为上传/绑定时的语义标签,不再影响读取。
|
||||
# 还原: 加回 owner_user_id 检查。
|
||||
return True
|
||||
|
||||
|
||||
# 根据当前脚本位置计算资源的相对路径,便于 Notebook 中用相对路径读取文件。
|
||||
|
||||
Reference in New Issue
Block a user