Add a course permission check to ContainerChildrenView
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
从 rest_api/v1/views/course_index.py 中的 ContainerChildrenView.get() 开始,并将其访问检查与 ContainerHandlerView 的访问检查进行比较。为无法访问课程的用户添加或更新测试,并确认请求会在 get_xblock 创建课程信息块之前返回 403。验证已授权用户仍然可以加载单元页面。
由索引模型根据 Issue 内容生成。
描述
Description
ContainerChildrenView does not check course access, so any authenticated user can request a container's children. It is backend only and needs a direct API call.
Current Behavior
rest_api/v1/views/course_index.py:125 only applies view_auth_classes(is_authenticated=True). Unlike its sibling ContainerHandlerView, it never calls _get_item_in_course, so no course access check runs. This also happens with the legacy access checks, and was already the case upstream.
Expected Behavior
Only users with view access to the course can list a container's children.
Steps to reproduce
Setup
- A course with at least one unit (vertical).
- A user with no access to that course: authenticated, not course staff, and with no AuthZ role on it.
Steps
-
In Studio, open any unit of the course as a user with access and copy its usage key from the URL, for example
block-v1:Org+Course+Run+type@vertical+block@abc123. -
Log in to Studio as the user with no access to the course.
-
Call the endpoint with that usage key (URL-encoded):
GET /api/contentstore/v1/container/{usage_key_string}/children -
Observe the response.
Result
- Actual:
200, with the container's children in the body. - Expected:
403.
For comparison, GET /api/contentstore/v1/container_handler/{usage_key_string} as the same user returns 403, because it goes through _get_item_in_course.
Acceptance Criteria
-
get()returns 403 for users withoutCOURSES_VIEW_COURSEon the container's course. - The check runs before anything else in
get(). - The unit page keeps working, since
container_handleralready requires the same permission. - Tests are added or updated.
Proposed Solution
At the top of get():
if not user_has_course_permission(
request.user, COURSES_VIEW_COURSE.identifier,
usage_key.course_key, LegacyAuthoringPermission.READ,
):
self.permission_denied(request)
Technical Notes
get_xblock creates course_info blocks on a GET when they do not exist (view_handlers.py:1140), so the permission check has to come before that.
- 主要语言
- Python
- 星标
- 0
- 派生
- 10
- 平均合并
- 5 天 9 小时
- 30 天内合并 PR
- 24
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
openedx/openedx-authz 的其他 Issue
-
willow
难度 2/5 1-3 小时 新手友好度 78/100
openedx/openedx-authz#597 ·
维护者通常 1 天内回复
-
willow
难度 2/5 1-3 小时 新手友好度 68/100
openedx/openedx-authz#579 ·
维护者通常 1 天内回复
-
Willow release testing可能已有人在做 @mariajgrimaldi 于 2 天前认领。 未关闭willow
openedx/openedx-authz#609 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Update Willow BTR test descriptions for current AuthZ behavior可能已有人在做 @mariajgrimaldi 于 2 天前认领。 未关闭willow
openedx/openedx-authz#608 · 已指派 1 人 ·
维护者通常 1 天内回复
-
willow
难度 5/5 一周以上 新手友好度 25/100
openedx/openedx-authz#605 ·
维护者通常 1 天内回复
查看 openedx/openedx-authz 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
igormcsouza/tether#278 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 91/100
aws-samples/sample-per-model-bedrock#803 ·
维护者通常 1 天内回复
-
documentation p1
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
huggingface/accelerate#4511 ·
维护者通常 1 天内回复
-
follow-up
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复