Skip to content

fix: let course_id bypass library access when reviewing pending updates - #39107

Open
efortish wants to merge 2 commits into
openedx:masterfrom
eduNEXT:ks/issue-441-library-review-authz
Open

efortish wants to merge 2 commits into
openedx:masterfrom
eduNEXT:ks/issue-441-library-review-authz

Conversation

@efortish

@efortish efortish commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

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_updates at 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_id query 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_id is present and the requesting user holds courses.view_library_updates in 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

  • Added regression tests covering the course_id bypass and the "no access to an unrelated course" case for all three endpoints, plus unit tests for the new user_has_course_permission_from_query_param helper.
  • Verified manually end to end against a devstack: a Course Auditor with zero library permissions gets 403 on all three endpoints without course_id, and 200 once course_id points at their course.

Deadline

None

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
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Sep 16, 2026
@openedx-webhooks

openedx-webhooks commented Sep 16, 2026

Copy link
Copy Markdown

Thanks for the pull request, @efortish!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform-oncall.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Ready for Review

Development

Successfully merging this pull request may close these issues.

3 participants