Repository navigation
Conversation
|
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. 🔘 Update the status of your PRYour PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate. 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Static assets referenced inside reviewed library content (images, etc.) still returned 403 for a Course Auditor, even after openedx#39107, because the asset URL is generated during content rendering (OpenedXContentRuntime's _absolute_url_for_asset) and resolved directly by the browser, not through a request the frontend controls. Thread downstream_block_id from embed_block_view into the runtime via load_block/get_runtime, so _absolute_url_for_asset can bake it into every asset URL it generates. LibraryComponentAssetView (used by both the published and draft asset endpoints) now does the same user_has_course_permission_for_upstream check the other endpoints use, resolving the component version back to its usage key via library_component_usage_key to verify the downstream is actually linked to it. Fixes openedx-authz#473.
723005d to
0dbfd34
Compare
Description
Builds on #39107 (this PR depends on it) to close the remaining gap in the course-review AuthZ bypass. Even after #39107 fixed the surrounding block and container endpoints, static assets (e.g., images) referenced by reviewed library content still returned
403 Forbiddenfor Course Auditors.Root Cause
Asset URLs are generated during content rendering by
OpenedXContentRuntime._absolute_url_for_asset()and resolved directly by the browser. Since these requests are not controlled by the frontend, there was no way to attachdownstream_block_idat request time.Solution
Propagate
downstream_block_idthrough the rendering pipeline so asset requests can be authorized against the downstream course context:load_blockandget_runtime(openedx/core/djangoapps/xblock/api.py) now acceptdownstream_block_idand pass it to the runtime.embed_block_viewforwards the existingdownstream_block_idquery parameter toload_block, reusing the context already used by its own authorization bypass check.OpenedXContentRuntimestores the downstream block ID and appends it as a query parameter to every asset URL it generates.get_component_version_asset, shared byLibraryComponentAssetViewandLibraryComponentDraftAssetView, resolves the component version to its usage key viaapi.library_component_usage_keyand applies the sameuser_has_course_permission_for_upstreamcheck used by the other endpoints. This ensures assets are served only when the component is actually linked to the specified downstream context.Fixes openedx/openedx-authz#473
Testing
LibraryComponentAssetAuthzBypassTesttotest_embed_block.py, covering:downstream_block_idis missing.xblock,content_libraries,content_stagingclipboard, andcontent/searchtest suites locally: 416 passed, 9 skipped, 0 failed.ruff,pylint, andlint-importsall pass.Dependencies
Depends on #39107, which must be merged before this PR can be merged.
Deadline
None.