Skip to content

feat: add authz permission for the course authoring list#38199

Merged
bmtcril merged 13 commits intoopenedx:masterfrom
WGU-Open-edX:dwong2708/authz-new-perms-course-list-endpoint
Apr 7, 2026
Merged

feat: add authz permission for the course authoring list#38199
bmtcril merged 13 commits intoopenedx:masterfrom
WGU-Open-edX:dwong2708/authz-new-perms-course-list-endpoint

Conversation

@dwong2708
Copy link
Copy Markdown
Contributor

@dwong2708 dwong2708 commented Mar 20, 2026

Refactor course access listing to single-pass hybrid AuthZ + legacy approach

Summary

This PR refactors get_courses_accessible_to_user to improve performance, readability, and maintainability by introducing a single-pass hybrid access evaluation model.

Instead of splitting courses into separate AuthZ and legacy pipelines and merging results afterward, this implementation evaluates access per course in a single pass, then performs a single batched query to retrieve the final course list.

Key Improvements

Single-pass access evaluation

  • Replaced the dual pipeline (AuthZ vs legacy) with a unified loop.
  • Each course is evaluated once using:
    - user_has_course_permission(...)
  • Eliminates duplicated logic and merging complexity.

Scoped full scan to staff users only

  • Staff users still require evaluating all courses (expected behavior).
  • Non-staff users now operate only on candidate course keys, avoiding unnecessary full table scans.
if is_staff_user:
    candidate_keys = CourseOverview.get_all_courses().values_list("id", flat=True)
else:
    candidate_keys = _get_candidate_course_keys(request)

Deferred object fetching

  • Only fetch full CourseOverview objects after access filtering
  • Reduces memory usage and DB overhead

Centralized filtering and ordering

  • Filters (search, active/archived, ordering) are applied once at the end
  • Ensures consistent behavior and avoids repeated processing

Improved readability and maintainability

  • Clear step-based flow:
  1. Determine candidate keys
  2. Evaluate access
  3. Batch fetch
  4. Apply filters
  • Reduced cognitive complexity and branching

Testing Notes

  • Existing tests should continue to pass without modification
  • Recommended additional coverage:
    • Mixed AuthZ + legacy access scenarios
    • Staff vs non-staff behavior
    • Empty access cases

Deadline

Verawood

Other information

Resolves: openedx/openedx-authz#190

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Mar 20, 2026
@openedx-webhooks
Copy link
Copy Markdown

openedx-webhooks commented Mar 20, 2026

Thanks for the pull request, @dwong2708!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform.

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 Mar 20, 2026
@dwong2708 dwong2708 force-pushed the dwong2708/authz-new-perms-course-list-endpoint branch from 25142ea to 96b100a Compare March 21, 2026 00:03
@dwong2708 dwong2708 changed the title Dwong2708/authz new perms course list endpoint feat: add authz permission for the course authoring list Mar 21, 2026
@dwong2708 dwong2708 marked this pull request as ready for review March 21, 2026 22:58
@mphilbrick211 mphilbrick211 added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label Mar 23, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Mar 23, 2026
Copy link
Copy Markdown
Contributor

@rodmgwgu rodmgwgu left a comment

Choose a reason for hiding this comment

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

It's looking good so far, just some comments

@dwong2708 dwong2708 force-pushed the dwong2708/authz-new-perms-course-list-endpoint branch from 78bf785 to 3cba95e Compare March 24, 2026 19:25
Copy link
Copy Markdown
Contributor

@rodmgwgu rodmgwgu left a comment

Choose a reason for hiding this comment

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

Just some questions and observations

@dwong2708 dwong2708 requested a review from rodmgwgu March 28, 2026 00:12
@dwong2708 dwong2708 force-pushed the dwong2708/authz-new-perms-course-list-endpoint branch from 234f420 to 29b8587 Compare March 30, 2026 17:12
@rodmgwgu
Copy link
Copy Markdown
Contributor

Just tested in my local, and it's working correctly.

Copy link
Copy Markdown
Member

@mariajgrimaldi mariajgrimaldi left a comment

Choose a reason for hiding this comment

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

Only a nit and a question left.

Looks good! Interested in testing how these changes perform against only legacy.

@dwong2708 dwong2708 force-pushed the dwong2708/authz-new-perms-course-list-endpoint branch 2 times, most recently from 279df59 to 4f56146 Compare April 2, 2026 03:01
Copy link
Copy Markdown
Member

@mariajgrimaldi mariajgrimaldi left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you so much for addressing all of my comments :)

Copy link
Copy Markdown
Contributor

@wgu-taylor-payne wgu-taylor-payne left a comment

Choose a reason for hiding this comment

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

Approving — these are all non-blocking nits.

@dwong2708 dwong2708 force-pushed the dwong2708/authz-new-perms-course-list-endpoint branch from 4f56146 to 63b5b1d Compare April 6, 2026 17:42
@mphilbrick211 mphilbrick211 moved this from Ready for Review to In Eng Review in Contributions Apr 6, 2026
@dwong2708 dwong2708 requested a review from bmtcril April 6, 2026 19:52
@bmtcril bmtcril merged commit a487617 into openedx:master Apr 7, 2026
48 checks passed
@github-project-automation github-project-automation bot moved this from In Eng Review to Done in Contributions Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Development

Successfully merging this pull request may close these issues.

Task - RBAC AuthZ - Implement new permissions for Course list

7 participants