Skip to content

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

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

feat: adding permissions checks related to course section and units#3200
jacobo-dominguez-wgu wants to merge 2 commits 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

openedx-webhooks commented Aug 19, 2026

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.

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.

@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.94%. Comparing base (2c14cef) to head (31b21c2).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3200      +/-   ##
==========================================
+ Coverage   95.93%   95.94%   +0.01%     
==========================================
  Files        1397     1397              
  Lines       33603    33657      +54     
  Branches     7687     7710      +23     
==========================================
+ Hits        32237    32293      +56     
+ Misses       1323     1321       -2     
  Partials       43       43              

☔ 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 :)

BryanttV added a commit to eduNEXT/frontend-app-authoring that referenced this pull request Aug 27, 2026
@jacobo-dominguez-wgu
jacobo-dominguez-wgu marked this pull request as ready for review August 31, 2026 15:14
@jacobo-dominguez-wgu

Copy link
Copy Markdown
Contributor Author

Dependency pr is merged openedx/openedx-platform#38986. This one is ready for review @bradenmacdonald

@jacobo-dominguez-wgu jacobo-dominguez-wgu moved this from Waiting on Author to Ready for Review in Contributions Aug 31, 2026
@jacobo-dominguez-wgu
jacobo-dominguez-wgu force-pushed the feat/course-access-content-2 branch from a422c46 to 5e312c5 Compare September 1, 2026 15:22
@dcoa

dcoa commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

I just noticed a small bug from part 1 . I thought was not related to our changes but it actually is.

When we hide the actions for the outline unit card, the footer is overflowing, as you can see in the following image

image

The solution is remove the item-children class in:

export const LEVEL_CONFIG: Record<Depth, LevelConfig> = {
0: {
name: 'section',
contentClass: 'section-card__content',
contentTestId: 'section-card__content',
childContainerClass: 'section-card__subsections',
childContainerTestId: 'section-card__subsections',
containerType: ContainerType.Subsection,
iconSize: 'md',
background: { padding: '1.75rem' },
},
1: {
name: 'subsection',
contentClass: 'subsection-card__content item-children',
contentTestId: 'subsection-card__content',
childContainerClass: 'subsection-card__units',
childContainerTestId: 'subsection-card__units',
containerType: ContainerType.Unit,
iconSize: 'sm',
background: { background: '#f8f7f6' },
},
2: {
name: 'unit',
contentClass: 'unit-card__content item-children',
contentTestId: 'unit-card__content',
iconSize: 'xs',
background: { background: '#fdfdfd' },
},
};

And add the class in OutlineNode.tsx component as follows:

className={levelConfig.contentClass}

                className={classNames(levelConfig.contentClass, {
                  // `item-children` pulls the content 2.75rem to the right so it spans
                  // under the drag handle column. Without the handle there is no column
                  // to fill, and the negative margin would overflow the card.
                  'item-children': isDraggable,
                })}

Can we implement it as part of the current PR?

@jacobo-dominguez-wgu

Copy link
Copy Markdown
Contributor Author

I just noticed a small bug from part 1 . I thought was not related to our changes but it actually is.
When we hide the actions for the outline unit card, the footer is overflowing, as you can see in the following image
Can we implement it as part of the current PR?

@dcoa Sure, it is implemented. Can you check again?

1: {
name: 'subsection',
contentClass: 'subsection-card__content item-children',
contentClass: 'subsection-card__content',

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.

Thank you for removing the class here, could you please do the same in unit (the second object in the array)?

@dcoa dcoa Sep 7, 2026

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.

Thank you I dont have any extra comments

@jacobo-dominguez-wgu
jacobo-dominguez-wgu force-pushed the feat/course-access-content-2 branch from 177802b to 31b21c2 Compare September 4, 2026 15:04

@BryanttV BryanttV 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.

Tested on my local and it works as expected, thanks!

@BryanttV

BryanttV commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

@jacobo-dominguez-wgu, sorry, while running some other tests, I noticed that the "Publish Changes" button is still visible to a Course Editor and Course Auditor, here:

image Could we fix that?

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: Ready for Review

Development

Successfully merging this pull request may close these issues.

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

7 participants