Repository navigation
Description
Description
Course and library permissions are managed separately, so a user can hold course permissions for library updates without being allowed to view the source library. As defined in the Library updates in Authoring product proposal, previewing, accepting, or ignoring an update must require permission to view the source library, in addition to the relevant course permission. This applies library access rules consistently and removes the authorization path through course references.
Current Behavior
| Action | Is library view access enforced? |
|---|---|
| Preview (container, container children, block metadata, block embed) | Not always. openedx/openedx-platform#39107 grants access through the course when the request includes a downstream_block_id whose upstream link points to the requested resource, and the user has courses.view_library_updates in that course. |
Accept (POST /api/contentstore/v2/downstreams/{usage_key}/sync) |
Yes, since the revert in openedx/openedx-platform#39336. A denied block sync is reported as an invalid upstream (400), while the container sync raises a permission error. |
Ignore (DELETE /api/contentstore/v2/downstreams/{usage_key}/sync) |
No. Only courses.manage_library_updates is checked. |
The course-based preview access trusts the upstream link stored in the course. That link can be set through course content, so it does not prove that the user is allowed to read the library item. See this review discussion.
Expected Behavior
| Action | Required permissions |
|---|---|
| Preview an update | Permission to view the source library. The course-level courses.view_library_updates permission no longer grants access to library content. |
| Accept an update | courses.manage_library_updates and permission to view the source library |
| Ignore an update | courses.manage_library_updates and permission to view the source library |
"Permission to view the source library" means CAN_VIEW_THIS_CONTENT_LIBRARY, which already covers AuthZ. It applies whether or not AuthZ course authoring is enabled for the course.
Users without library access can still view the content already incorporated into the course and can still see that updates are available. The course keeps its current version until an authorized user accepts the update.
So that the frontend can show the right actions, the downstreams summary (GET /api/contentstore/v2/downstreams/{course_key}/summary) reports for each source library whether the current user can view it:
{
"upstream_context_key": "lib:Org:Lib",
"can_view_upstream_library": false
}Acceptance Criteria
Preview
- The following endpoints require permission to view the source library, and a
downstream_block_idquery parameter does not grant access:-
GET /api/libraries/v2/containers/{container_key}/ -
GET /api/libraries/v2/containers/{container_key}/children/ - The library block metadata endpoint changed in fix: allow course users to review pending library updates openedx-platform#39107
-
GET /xblocks/v2/{usage_key}/embed/{view_name}/
-
- The course-based bypass added in fix: allow course users to review pending library updates openedx-platform#39107 (
user_has_course_permission_for_upstream) and its tests are removed.
Accept and ignore
-
POSTandDELETEon/api/contentstore/v2/downstreams/{usage_key}/syncrequire bothcourses.manage_library_updatesand permission to view the source library. - Both methods return
403when the user can manage library updates in the course but cannot view the source library, for components and for containers. - A rejected request does not modify the course. In particular, a rejected accept of a video component does not delete its transcripts, and a rejected ignore does not record a declined version.
- Users with both permissions can accept and ignore updates as before.
Library access in the summary
- Each item in the downstreams summary response includes a boolean
can_view_upstream_libraryfor the current user. The existing fields do not change. - The value is based on the same rule that is enforced for preview, accept, and ignore, including access granted by AuthZ, public read, and legacy library permissions.
- The value is
falseif the source library no longer exists, and the request does not fail. - The API documentation of the endpoint includes the new field.
Unchanged behavior
- The downstreams list, the downstreams summary, and the upstream link information of course blocks still report available updates to users without library access, subject to their existing course permission checks.
- Course content that was already incorporated from a library remains viewable to users who can view the course.
Tests
- Tests cover preview, accept, and ignore for users with and without library view access, for components and containers, with AuthZ course authoring enabled and disabled.
- Tests cover
can_view_upstream_libraryfor users with and without library view access, including a course that uses both accessible and restricted libraries.
Out of Scope
- Frontend changes, tracked in Task - implement library updates #319.
- Changes to the legacy Studio unit page.
- Backporting to Verawood.
Technical Notes
cms/djangoapps/contentstore/rest_api/v2/views/downstreams.py:SyncFromUpstreamViewand_load_accessible_block. ThePOSThandler callsclear_transcripts()before the library permission is checked, so the check must happen first.cms/lib/xblock/upstream_sync.py:decline_sync()performs no library permission check.cms/lib/xblock/upstream_sync_block.py(_load_upstream_block) turnsPermissionDeniedintoBadUpstream, which the view returns as400.cms/lib/xblock/upstream_sync_container.py:sync_from_upstream_container()already requiresCAN_VIEW_THIS_CONTENT_LIBRARY.DownstreamSummaryViewandPublishableEntityLinksSummarySerializer(cms/djangoapps/contentstore/rest_api/v2/serializers/downstreams.py): the summary is already grouped by library, so the permission only needs to be checked once per library.- Bypass call sites:
openedx/core/djangoapps/authz/decorators.pyopenedx/core/djangoapps/content_libraries/rest_api/containers.pyopenedx/core/djangoapps/content_libraries/rest_api/blocks.pyopenedx/core/djangoapps/xblock/rest_api/views.py
- The legacy Studio preview modal still sends
downstream_block_id. It does not need to change, since the parameter will have no effect. - Library asset URLs (
/library_assets/component_versions/...) already require library view access, so they need no change.
Related Issues
This change supersedes the earlier approach of granting library access through course permissions:
- Replaces the expected behavior of Course Admin/Staff/Editor cannot sync library updates into a course #419 (accept without library access).
- Replaces the expected behavior of Fix review endpoints to allow access for users with
courses.view_library_updatespermission #441 (preview without library access). - Makes Library asset URLs (images, etc.) embedded in reviewed content still 403 for course_id bypass #473 unnecessary. It should be closed.
- fix: extend course-review authz bypass to embedded library asset URLs openedx-platform#39248 should be closed.
- fix: pass course context to library review endpoints frontend-app-authoring#3251 should be closed.
- Frontend counterpart: Task - implement library updates #319.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn Review
Activity
fix: require library view access to preview, accept, or ignore librar…