feat: include authz course role assignments in Meilisearch access_ids - #39073
feat: include authz course role assignments in Meilisearch access_ids#39073wgu-taylor-payne wants to merge 1 commit into
Conversation
|
Thanks for the pull request, @wgu-taylor-payne! This repository is currently maintained by 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 approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf 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 PRYour 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:
💡 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.
66be8d2 to
5d245c8
Compare
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_requestbuilds the per-user tenant-token filter that Meilisearch enforces server-side. Until now that filter was built from legacyCourseStaffRole/CourseInstructorRoleassignments only.Users who hold an authz-only course role —
course_editororcourse_auditorgranted through openedx-authz, with no corresponding legacyCourseAccessRolerow — 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_keyshelper that unions the user's authz course-role assignments into theaccess_idfilter whenAUTHZ_COURSE_AUTHORING_FLAGis enabled. The flag is aCourseWaffleFlag, 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
DatabaseErrorfrom 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 viaInvalidKeyError.Impacted user roles: Course Author (editors/auditors who rely on authz roles), Operator (behavior is gated behind
AUTHZ_COURSE_AUTHORING_FLAG).Supporting information
view_library_updatesenforcement work in Addcourses.view_library_updatesenforcement in openedx-platform openedx-authz#398 and PR feat: split read vs write authz checks for library updates #39009.Testing instructions
AUTHZ_COURSE_AUTHORING_FLAG(globally, or as a per-course override for the course under test).course_editor(orcourse_auditor) role on a course, and no legacyCourseStaffRole/CourseInstructorRoleon it.pytest openedx/core/djangoapps/content/search/tests/test_models.py— seeStudioSearchAuthzAccessTest(authz-only user sees courses with flag on,omit_orgsapplies, flag-off excludes,DatabaseErrorswallowed, unexpected error propagates, unparseable scope skipped, legacy+authz de-duplicate).Deadline
None.
Other information
AUTHZ_COURSE_AUTHORING_FLAGresolves enabled for a given course; with the flag off everywhere and no overrides,access_idsare unchanged from today.get_user_role_assignments_per_scope_typeeagerly expands each role's implicit permissions, but this helper only readsscope.external_keyand 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.