feat: Implement courses roles and permissions mappings#217
feat: Implement courses roles and permissions mappings#217rodmgwgu merged 1 commit intoopenedx:mainfrom
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. |
wgu-taylor-payne
left a comment
There was a problem hiding this comment.
This looks good. Just one comment regarding the version number.
dwong2708
left a comment
There was a problem hiding this comment.
LGTM, just one suggestion in the legacy roles mapping.
| COURSE_BETA_TESTER = RoleData(external_key="course_beta_tester", permissions=COURSE_BETA_TESTER_PERMISSIONS) | ||
|
|
||
| # Map of legacy course role names to their equivalent new roles | ||
| LEGACY_COURSE_ROLE_EQUIVALENCES = { |
There was a problem hiding this comment.
Is it possible to reverse the mapping order?
For example:
{
COURSE_ADMIN.external_key: "instructor",
...
}
Reason: while working on the migration, during rollback (authz → legacy), I only have access to new_role.key, so I need a way to map it back to the corresponding legacy role.
There was a problem hiding this comment.
This is how I'm doing it in openedx-platform: https://github.com/WGU-Open-edX/openedx-platform/blob/5dc65a27a4cfc9f8045ab71fca19965f7127f488/common/djangoapps/student/roles.py#L39
I also need it both ways there, I did it that way to avoid having to maintain two maps, what do you think?
There was a problem hiding this comment.
Sounds good, just one consideration.
If we have a mapping like:
{
"instructor": "admin",
"staff": "admin",
}
get_legacy_role_from_authz_role would just pick the first match. Not sure if this case is expected, but maybe we should add a comment here or in the function to clarify the behavior.
There was a problem hiding this comment.
mmm where do you see that? instructor is "admin" but staff should be "staff" as documented here: https://github.com/rodmgwgu/openedx-authz/blob/385e76d4e95381bb6533df5272ecff6593e09156/docs/decisions/0011-course-authoring-migration-process.rst (Role Mapping table)
There was a problem hiding this comment.
The mapping above is just an example in case this situation occurs. What I’m trying to highlight is that if an authz role maps to multiple legacy roles, get_legacy_role_from_authz_role will pick the first one. For this reason, a comment like the following could help prevent unexpected results:
"This mapping must be unique in both directions, since it may be used as a reverse lookup (value → key). If multiple keys share the same value, it will lead to collisions."
There was a problem hiding this comment.
oh ok, I'll add that comment, thanks!
There was a problem hiding this comment.
done, comment added, thanks!
| effect="allow", | ||
| ) | ||
|
|
||
| EDIT_DETAILS = PermissionData( |
There was a problem hiding this comment.
Something else came to mind. I think that some of these constant names could be more descriptive. Since we have library related permissions, course permissions, and in the future other permissions in this file, it would be good to rename some of these like EDIT_DETAILS, VIEW_FILES, etc. to show somehow that they are course related. Another option would be to scope the various permission namespaces to their own modules (e.g. course_permissions.py, library_permissions.py).
There was a problem hiding this comment.
+1 on more descriptive constant names. I think the long term plan is still to move these to plugin-style implementations closer to the code that uses them once we have that functionality in place so I'm a little less worried about getting them in the right place in this repo right now.
There was a problem hiding this comment.
I'm adding the "COURSES_" prefix to all course-related permissions, I won't change Library permissions to avoid breaking stuff.
bmtcril
left a comment
There was a problem hiding this comment.
I think this is good to go once the remaining feedback is addressed. Approving now so I'm not blocking while I'm out.
…acy compat permissions
16e67e8 to
fb491c3
Compare
Implemented courses roles and permissions mappings, including legacy compatible permissions and role equivalences.
Permissions implemented as specified here: https://openedx.atlassian.net/wiki/spaces/OEPM/pages/5528715266/openedx-authz+permission+list
Roles implemented as specified here: https://openedx.atlassian.net/wiki/spaces/OEPM/pages/5638619138/Authoring+Roles+and+Permissions
Equivalent legacy roles implemented as specified here: https://github.com/rodmgwgu/openedx-authz/blob/385e76d4e95381bb6533df5272ecff6593e09156/docs/decisions/0011-course-authoring-migration-process.rst
Closes: #189
Required for: openedx/openedx-platform#38013
Merge checklist:
Check off if complete or not applicable: