feat(page-and-resources): implement view and edit permission checks#3031
feat(page-and-resources): implement view and edit permission checks#3031bra-i-am wants to merge 10 commits intoopenedx:masterfrom
Conversation
|
Thanks for the pull request, @bra-i-am! 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. DetailsWhere 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. |
- Add VIEW_ADVANCED_SETTINGS and PAGE_AND_RESOURCES permissions
- Add getPagesAndResourcesPermissions helper
- Calculate isEditable and isReadOnly from user permissions
- Propagate isEditable via PagesAndResourcesContext
- Add disabled={!isEditable} to all forms, toggles, and buttons
- Update AppCard and AppListNextButton with isEditable logic
- Change default isEditable to false (fail closed)
- Add unified permission gate showing PermissionDeniedAlert
5bf47e2 to
bf1f32a
Compare
27c140e to
2768600
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3031 +/- ##
==========================================
+ Coverage 95.47% 95.52% +0.05%
==========================================
Files 1383 1392 +9
Lines 32597 32923 +326
Branches 7466 7578 +112
==========================================
+ Hits 31121 31450 +329
+ Misses 1407 1406 -1
+ Partials 69 67 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7bed3bd to
c842c4a
Compare
05d2b74 to
8d98c60
Compare
…/resources access
8d98c60 to
699af15
Compare
…d refactor related components
… related components
…ove accessibility attributes
…onfigForm and PageCard tests


Description
Implements read-only access (RBAC) for the
course_auditorrole across the Pages and Resources and Advanced Settings sections.This PR closes #2933 and additionally extends VIEW permissions to the Advanced Settings section, which was not originally scoped in the issue but required the same treatment for consistency.
What this PR does
Pages and Resources (closes #2933)
VIEW_PAGES_AND_RESOURCESpermission constant tosrc/authz/constants.tsgetPagesAndResourcesPermissionshelper insrc/authz/permissionHelpers.tsto fetch user permissions from the authz backendisEditablefrom resolved permissions:!isAuthzEnabled || !!canManagePagesAndResourcesisEditable = true— legacy behavior fully preservedisEditableistrueonly for users with MANAGE permissionisEditablethroughPagesAndResourcesContextto all child componentsdisabled={!isEditable}to all interactive elements:AppCard.jsxAppListNextButton.jsxAppList.jsxPageSettingButton.jsxAppSettingsModal.jsxplugins/course-apps/progress/Settings.jsxPermissionDeniedAlertgate for users who lack both VIEW and MANAGE permissionsAdvanced Settings (additional scope)
VIEW_ADVANCED_SETTINGSpermission constant tosrc/authz/constants.tsAdvancedSettings.tsxto fetch and respect theisEditableflag, disabling all setting cards and inputs when the user only has VIEW permissionSettingCard.tsxto accept and forward adisabledprop to its inner inputsRole impact
course_auditorcourse_editor/course_staff/course_adminDependencies
This PR is part of a 3-layer change and requires the following backend PRs to be merged first:
openedx-authzCOURSES_VIEW_ADVANCED_SETTINGSpermission constant; assigns it tocourse_auditorandcourse_editorroles in the policy engineopenedx-platformcheck_course_advanced_settings_access()instudent/auth.pyto return full-access for MANAGE permission holders and read-only access for VIEW-only holders (auditors); preserves legacy fallback whenAUTHZ_COURSE_AUTHORING_FLAGis disabledTesting instructions
AUTHZ_COURSE_AUTHORING_FLAGfeature flag.course_auditorrole to a test user for a specific course.course_editorand verify full write access is still present on both pages.AUTHZ_COURSE_AUTHORING_FLAGand verify the legacy fallback still works correctly.Best Practices Checklist
src/authz/permissionHelpers.test.ts)PagesAndResourcesContext) to propagateisEditable— no prop drilling