Skip to content

feat: adding permissions checks related to course section and units - #3200

Draft
jacobo-dominguez-wgu wants to merge 1 commit into
openedx:masterfrom
WGU-Open-edX:feat/course-access-content-2
Draft

feat: adding permissions checks related to course section and units#3200
jacobo-dominguez-wgu wants to merge 1 commit into
openedx:masterfrom
WGU-Open-edX:feat/course-access-content-2

Conversation

@jacobo-dominguez-wgu

@jacobo-dominguez-wgu jacobo-dominguez-wgu commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Description

Continuation of #3196. That PR added permission checks to the course outline home page; this one extends the same authorization model to the course section and unit (internal) pages.

It conditionally renders, hides, or disables the editable and publishable elements on the section/unit pages so that users only interact with the actions their role permits, applying "read-only" states or removing modification/publish actions as defined by the design.

Concretely, on the unit and section pages the following are now gated:
edit_course_content — when the user lacks this permission, content-editing affordances become read-only or hidden, including:

  • Unit header actions: the Add component action and the title Edit button (and the Edit action on legacy library-content / split-test pages).
  • The Add component and Paste strips on the unit page.
  • XBlock/item actions exposed through the unit sidebar menu (duplicate, delete, unlink, move, copy, manage tags, etc.).
  • The unit sidebar footer Discard changes and Copy actions.
  • The access/visibility form controls in the configure modal (unit visibility checkbox, group access select and group checkboxes, discussion checkbox) and the shared visibility settings (Student Visible / Staff Only buttons and the "hide after due" checkbox).
    publish_course_content — when the user lacks this permission, the Publish action in the unit sidebar footer is hidden.

Permissions are resolved through the shared CourseAuthoringProvider (useCourseAuthoringContext), which now exposes canEditCourseContent and canPublishCourseContent via useCourseUserPermissions, consistent with #3196.

AI usage notice: used Claude Opus 4.8 through kiro to assist on the modification and creation of unit tests.

Permission Matrix

Category Permission Course Editor Course Auditor
Course Access & Content courses.view_course
courses.create_course
courses.publish_course_content
courses.edit_course_content

Important

The publish and content edition options specific to the xblocks will be handled in a different pr.
image

Impacted user roles: Course Author / Course Editor and Course Auditor (and any role mapped to the permissions above).

Supporting information

Continuation of #3196 (course outline home page).
Partially closes openedx/openedx-authz#383.
Needs openedx/openedx-authz#384
Figma: «link»
Note: permissions related to Tags are handled in a separate ticket (openedx/openedx-authz#314).

Testing instructions

Depends on openedx/openedx-authz#384.

Requirements

Enable the authz.enable_course_authoring waffle flag.
You can set course_auditor or course_editor role to a user using the API <lms_url>/api-docs/#/authz/authz_v1_roles_users_update
Payload example:

{
  "role": "course_auditor", // role
  "scope": "course-v1:OpenedX+DemoX+DemoCourse", //courseId
  // use scopes instead of scope if you need to set more than 1 resource
  "users": [
    "my_username" // username or email
  ]
}

Test case 1 — course_auditor

  1. Log in as a user with the course_auditor role on the course.
  2. Open a unit page (and open a section/subsection configure modal from the outline).
  3. Confirm the unit content and settings are visible but not editable: no Add/Paste, no title Edit, no sidebar item actions, no Publish/Discard/Copy, and the configure-modal access/visibility controls are disabled.

These elements must not be visible:
image

These elements must be visible but disabled (read-only, not clickable)
image

Test case 2 — course_editor

  1. Log in as a user with the course_editor role on the course.
  2. Open a unit page and a configure modal.
  3. Confirm the user can add/edit content (Add/Paste, title Edit, item actions, editable access/visibility controls) but the Publish action is not available.
image

Test case 3 — other roles (staff, superuser, course_admin, course_staff)

  1. Log in with a role other than course_editor/course_auditor.
  2. Open a unit page and configure modal.
  3. Confirm all add/edit/publish affordances are visible and fully functional (no regression).

Also verify that with the authz.enable_course_authoring flag disabled, everything behaves exactly as before (all permissions fall back to granted).

Best Practices Checklist

We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:

  • Any new files are using TypeScript (.ts, .tsx).
  • Avoid propTypes and defaultProps in any new or modified code.
  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks)
  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components.
  • Use React Query to load data from REST APIs. See any apiHooks.ts in this repo for examples.
  • All new i18n messages in messages.ts files have a description for translators to use.
  • Avoid using ../ in import paths. To import from parent folders, use @src, e.g. import { initializeMocks } from '@src/testUtils'; instead of from '../../../../testUtils'

Warning

Will be in draft status until the 403 problem is fixed openedx/openedx-authz#384

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Aug 19, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @jacobo-dominguez-wgu!

This repository is currently maintained by @bradenmacdonald.

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.

🔘 Update the status of your PR

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

  • 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.

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.92%. Comparing base (67cee5c) to head (a422c46).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3200      +/-   ##
==========================================
+ Coverage   95.88%   95.92%   +0.04%     
==========================================
  Files        1397     1397              
  Lines       33554    33597      +43     
  Branches     7893     7666     -227     
==========================================
+ Hits        32172    32228      +56     
- Misses       1323     1325       +2     
+ Partials       59       44      -15     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mphilbrick211 mphilbrick211 added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label Aug 19, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Aug 19, 2026
@jesusbalderramawgu

jesusbalderramawgu commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

I have tested all the scenarios and it works as expected.
Thank you!

@jesusbalderramawgu jesusbalderramawgu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bradenmacdonald

Copy link
Copy Markdown
Contributor

Please ping me to review once the other PR(s) is merged and this is ready :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

Course Auditor receives 403 error when navigating to course units Task - Implement Course Access & Content

5 participants