feat: Add validation for Advanced Settings permissions using openedx-authz#2869
Conversation
|
Thanks for the pull request, @rodmgwgu! 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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2869 +/- ##
==========================================
+ Coverage 95.21% 95.22% +0.01%
==========================================
Files 1318 1328 +10
Lines 30018 30535 +517
Branches 6543 6917 +374
==========================================
+ Hits 28582 29078 +496
- Misses 1379 1388 +9
- Partials 57 69 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| showSaveSettingsPrompt(true); | ||
| }; | ||
|
|
||
| if (isAuthzEnabled) { |
There was a problem hiding this comment.
This can be simplified with something like:
const hasPermissionToManage = isAuthzEnabled
&& !isLoadingUserPermissions
&& !userPermissions?.canManageAdvancedSettings;
if (hasPermissionToManage) {
return <PermissionDeniedAlert />;
}
There was a problem hiding this comment.
I wanted to make it clear that that code snipped will only run when isAuthzEnabled. But I guess I can do that with a comment, I'll change that, thanks
dwong2708
left a comment
There was a problem hiding this comment.
LGTM, just a couple of optional suggestions.
|
Just a small comment: I noticed this PR isn’t linked to the issue. I’m guessing it’s because it says “Related issue: link…”. You might want to change it to “Resolves: link…” instead. |
Description
Resolves: #2831
As part of the AuthZ for course authoring project Milestone 0, we are implementing more granular permission checks, starting with the Advanced Settings section.
This PR adds permission checks on:
The permission checks are only done if the "authz.enable_course_authoring" feature flag is enabled, otherwise the existing behavior is maintained.
Supporting information
Testing instructions
First, choose or create a course to test, in this example we will be using "course-v1:OpenedX+DemoX+DemoCourse"
With the flag disabled
When the flag is disabled, current behavior is maintained:
/admin/waffle_utils/waffleflagcourseoverridemodel/With the flag enabled and with a user with no "courses.manage_advanced_settings" permission:
/admin/waffle_utils/waffleflagcourseoverridemodel/Other information
Depends on:
Best Practices Checklist
We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:
.ts,.tsx).propTypesanddefaultPropsin any new or modified code.src/testUtils.tsx(specificallyinitializeMocks)apiHooks.tsin this repo for examples.messages.tsfiles have adescriptionfor translators to use.../in import paths. To import from parent folders, use@src, e.g.import { initializeMocks } from '@src/testUtils';instead offrom '../../../../testUtils'