Skip to content

feat: add authz validation to course optimizer tool - #39113

Open
dcoa wants to merge 1 commit into
openedx:masterfrom
eduNEXT:dcoa/couse-optimizer-authz
Open

dcoa wants to merge 1 commit into
openedx:masterfrom
eduNEXT:dcoa/couse-optimizer-authz

Conversation

@dcoa

@dcoa dcoa commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Description

This PR updates the course optimizer endpoints with authz permissions systems. The frontend validates access to the tool with edit permissions but the actions are still using the previous authorization system.

With this change, roles such as course editors can run the Course Optimizer. All four endpoints check the openedx-authz courses.edit_course_content permission.

Testing instructions

Setup

  1. Create three users (for example editor, auditor). None of them should be global staff or have legacy course roles.
  2. Turn on the Course Optimizer for your test course. In Studio Django admin (/admin/waffle_utils/waffleflagcourseoverridemodel/), add a course override set to Force On for:
    • contentstore.enable_course_optimizer
    • contentstore.enable_course_optimizer_check_prev_run_links (only needed for scenario 4)
  3. Turn on authz for the same course with a course override for authz.enable_course_authoring, set to Force On.
  4. Assign authz roles in that course, either through the Admin Console or from a shell.

Scenario 1: a course editor can use the tool

  1. Log in to the authoring MFE as editor and open the course.
  2. Check the menu: under Tools, Course Optimizer is listed.
  3. Start a scan: open it and click Start scan.
    • POST /api/contentstore/v0/link_check/<course_id> returns 200 {"LinkCheckStatus": "Pending"}.
    • Polling GET /api/contentstore/v0/link_check_status/<course_id> returns 200, and the scan results appear.
  4. Compare with the old code: both calls returned 403.

Scenario 2: a course auditor is denied

  1. Log in as auditor. Course Optimizer is not in the Tools menu.
  2. Run GET <studio>/api/contentstore/v0/link_check_status/<course_id> and <studio>/api/contentstore/v0/rerun_link_update_status/<course_id>. Both return 403.

Scenario 3: behaviour is unchanged when authz is off

  1. Delete the authz.enable_course_authoring override, or use a second course that has only the optimizer flag.
  2. Add a user as Staff through the legacy Course Team page. They can run a scan and see the results, as before.
  3. editor, who only has an authz role, now gets 403, because only the legacy roles are checked.

Scenario 4: previous-run link updates (optional)

This needs contentstore.enable_course_optimizer_check_prev_run_links and a rerun course whose content links to the original run.

  1. As editor, scan the rerun. The results list links that point to the previous run.
  2. Update one link: click Update on it. POST /api/contentourse_id> with {"action": "single", ...} returns 200.Polling rerun_link_update_status returns 200 with results.
  3. Update all links: click Update all. {"action": "all"} returns 200.
  4. As auditor, call the same endpoints. Both return 403.

@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 Sep 17, 2026
@openedx-webhooks

openedx-webhooks commented Sep 17, 2026

Copy link
Copy Markdown

Thanks for the pull request, @dcoa!

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.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Sep 17, 2026
@dcoa
dcoa marked this pull request as ready for review September 17, 2026 02:18
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Sep 17, 2026
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). 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