Skip to content

feat: include authz course role assignments in Meilisearch access_ids - #39073

Draft
wgu-taylor-payne wants to merge 1 commit into
openedx:masterfrom
WGU-Open-edX:tpayne/fix-meilisearch-access-ids-authz
Draft

feat: include authz course role assignments in Meilisearch access_ids#39073
wgu-taylor-payne wants to merge 1 commit into
openedx:masterfrom
WGU-Open-edX:tpayne/fix-meilisearch-access-ids-authz

Conversation

@wgu-taylor-payne

@wgu-taylor-payne wgu-taylor-payne commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Description

Studio search is powered by Meilisearch. On each request to the Studio search token endpoint (GET /api/content_search/v2/studio/), get_access_ids_for_request builds the per-user tenant-token filter that Meilisearch enforces server-side. Until now that filter was built from legacy CourseStaffRole / CourseInstructorRole assignments only.

Users who hold an authz-only course role — course_editor or course_auditor granted through openedx-authz, with no corresponding legacy CourseAccessRole row — were therefore invisible to the filter, and their courses returned zero results in the global Studio search modal (search icon / Cmd+K) and the "Review Content Updates" tab on the Library Updates page (/course/{id}/libraries), which uses Meilisearch to look up component details.

This change adds a _get_authz_course_keys helper that unions the user's authz course-role assignments into the access_id filter when AUTHZ_COURSE_AUTHORING_FLAG is enabled. The flag is a CourseWaffleFlag, so the check is applied per course — a deployment running the flag globally-off with per-course or per-org overrides still resolves correctly.

The lookup fails open: a DatabaseError from the authz/Casbin backend is logged and degrades to legacy-role access rather than returning a 500, while any unexpected exception propagates so real bugs surface. A non-course scope key (e.g. a library scope) is skipped via InvalidKeyError.

Impacted user roles: Course Author (editors/auditors who rely on authz roles), Operator (behavior is gated behind AUTHZ_COURSE_AUTHORING_FLAG).

Supporting information

Testing instructions

  1. Enable AUTHZ_COURSE_AUTHORING_FLAG (globally, or as a per-course override for the course under test).
  2. Create a user with an authz course_editor (or course_auditor) role on a course, and no legacy CourseStaffRole/CourseInstructorRole on it.
  3. As that user, open the global Studio search modal and search for content in that course — the course's content now appears (previously: zero results).
  4. Open the course's Library Updates page → "Review Content Updates" tab and confirm component details resolve.
  5. Automated: pytest openedx/core/djangoapps/content/search/tests/test_models.py — see StudioSearchAuthzAccessTest (authz-only user sees courses with flag on, omit_orgs applies, flag-off excludes, DatabaseError swallowed, unexpected error propagates, unparseable scope skipped, legacy+authz de-duplicate).

Deadline

None.

Other information

  • Feature-flagged. Behavior only changes when AUTHZ_COURSE_AUTHORING_FLAG resolves enabled for a given course; with the flag off everywhere and no overrides, access_ids are unchanged from today.
  • Performance / follow-up (not blocking): the authz assignments are fetched and then flag-filtered per course. get_user_role_assignments_per_scope_type eagerly expands each role's implicit permissions, but this helper only reads scope.external_key and discards the permissions — wasted work for users with many assignments. The computation runs once per token fetch (not per keystroke — the frontend reuses the minted tenant token for subsequent queries). A scopes-only authz API, and/or caching the computed access set with an explicit invalidation contract on role/flag change, would be the clean optimization; both are intentionally left out of this correctness fix.
  • No database migrations.

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

Copy link
Copy Markdown

Thanks for the pull request, @wgu-taylor-payne!

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.

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

get_access_ids_for_request built the Meilisearch tenant-token filter from
legacy CourseStaffRole/CourseInstructorRole only, so users holding an
authz-only course role (course_editor / course_auditor without a legacy
role) were excluded from the search access filter. Their courses returned
zero results in the global Studio search modal and the Library Updates
"Review Content Updates" tab.

Add a _get_authz_course_keys helper that unions the user's authz
course-role assignments into the access_id filter when
AUTHZ_COURSE_AUTHORING_FLAG is enabled, gated per-course so global-off
deployments with per-course/org overrides still resolve correctly.
@wgu-taylor-payne
wgu-taylor-payne force-pushed the tpayne/fix-meilisearch-access-ids-authz branch from 66be8d2 to 5d245c8 Compare September 2, 2026 21:30
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: Needs Triage

Development

Successfully merging this pull request may close these issues.

Studio search (Meilisearch) does not include courses for authz-only users

2 participants