Add a course permission check to ContainerChildrenView
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- authorization, backend-api-design, testing
Hướng nghiên cứu
Bắt đầu tại rest_api/v1/views/course_index.py, ở ContainerChildrenView.get(), rồi so sánh kiểm tra quyền truy cập của nó với ContainerHandlerView. Thêm hoặc cập nhật các bài kiểm thử cho người dùng không có quyền truy cập khóa học và xác nhận yêu cầu trả về 403 trước khi get_xblock có thể tạo các khối thông tin khóa học. Xác minh người dùng được cấp quyền vẫn có thể tải trang đơn vị.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 0
- Fork
- 10
- Merge trung bình
- 5 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 24
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của openedx/openedx-authz
-
willow
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
openedx/openedx-authz#597 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
willow
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
openedx/openedx-authz#579 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Willow release testingCó thể đã có người làm @mariajgrimaldi đã nhận 1 ngày trước. Đang mởwillow
openedx/openedx-authz#609 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Update Willow BTR test descriptions for current AuthZ behaviorCó thể đã có người làm @mariajgrimaldi đã nhận 1 ngày trước. Đang mởwillow
openedx/openedx-authz#608 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
willow
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
openedx/openedx-authz#605 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của openedx/openedx-authz
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
aws-samples/sample-per-model-bedrock#795 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Pretalx reports older version to be the latest release than what is actually installed and availableĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
micropython/micropython#19906 ·
Maintainer thường phản hồi trong vòng 1 ngày