Conversation
The library container and xblock embed endpoints used by the "review pending changes" modal only checked direct library permissions, so a Course Auditor (or any role holding courses.view_library_updates) got a 403 even though they should be able to review changes from their course. Accept an optional course_id query param on these three endpoints and grant access via courses.view_library_updates when it points to a course the user can review from, falling back to the existing library-level check otherwise. Same pattern already used for the sync endpoint in openedx#39009 and openedx#39055. Related to openedx/openedx-authz#441
|
Thanks for the pull request, @efortish! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
mypy needs check_permission annotated as CheckPerm | None explicitly, since the first assignment alone made it infer plain CheckPerm. Move the embed view's authz bypass test out of test_runtime.py (a plain TestCase, missing CORS_ORIGIN_WHITELIST in the CMS test environment) into test_embed_block.py, next to the other embed view tests, using the same override_settings(CORS_ORIGIN_WHITELIST=[]) workaround already in place there for the same reason.
Description
The library container endpoints and the xblock embed endpoint used by the "review pending changes" modal (opened from a course unit when a library-sourced component has updates available) only checked direct library permissions. That means a Course Auditor, or anyone else holding
courses.view_library_updatesat the course level, gets a 403 trying to review changes even though they can view everything else about that course.This adds an optional
course_idquery param to the three affected endpoints:GET /api/libraries/v2/containers/<container_id>/GET /api/libraries/v2/containers/<container_id>/children/GET /xblocks/v2/<usage_key>/embed/<view_name>/When
course_idis present and the requesting user holdscourses.view_library_updatesin that course, access is granted without requiring direct library permissions. Without it, or if the check fails, the existing library-level permission check runs exactly as before, so nothing changes for callers that don't pass it.This is the same approach already used for the sync endpoint in #39009 and #39055.
The companion frontend change (threading the course id through to these three calls) is in openedx/frontend-app-authoring#3251.
Related to openedx/openedx-authz#441
Testing
user_has_course_permission_from_query_paramhelper.course_id, and 200 oncecourse_idpoints at their course.Deadline
None