Repository navigation
feat: enforce AuthZ permissions in the Course Team endpoints - #39365
Conversation
Migrate the Course Team endpoints of the Instructor Dashboard API v2 from CourseTeamPermission to InstructorAuthzPermission: - CourseTeamRolesView (GET): courses.view_course_team - CourseTeamView (GET): courses.view_course_team - CourseTeamView (POST): courses.manage_course_team - CourseTeamMemberView (DELETE): courses.manage_course_team
|
Thanks for the pull request, @carlos-marquez-wgu! 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. |
|
Hi @openedx/wg-maintenance-openedx-platform-oncall, this PR is ready for reviews, thanks! |
There was a problem hiding this comment.
Hi @carlos-marquez-wgu, thanks a lot for the changes!
Something we need to check across all endpoints is access for Authz roles that don't have a legacy equivalent, that is, Authz roles other than Course Admin or Course Staff. Using the extension mechanism, I created a role (e.g., Instructor Dashboard Manager) that only has permissions related to the Instructor Dashboard, and assigned it to a user.
Currently, it returns a 403 on 3 out of the 4 views, and from what I see in the code, it's because it is still validating internally using has_access(request.user, 'instructor', course). We should also migrate those checks inside the handlers.
Additionally, I see that the CourseTeamPermission class ends up being dead code. Can we remove it, given that the has_course_team_access function has the same behavior?
Description
Migrate the Course Team endpoints of the Instructor Dashboard API v2 from
CourseTeamPermissiontoInstructorAuthzPermission:CourseTeamRolesView(GET):courses.view_course_teamCourseTeamView(GET):courses.view_course_teamCourseTeamView(POST):courses.manage_course_teamCourseTeamMemberView(DELETE):courses.manage_course_teamThe behavior follows the
authz.enable_course_authoringwaffle flag, as introduced in #39255:course_limited_staff,course_data_researcher,course_beta_tester). Those fall back to the legacy check when AuthZ denies, so they keep their legacy access.Affected roles: Course Admin, Course Staff, legacy course instructors and Discussion Admins.
Supporting Information
Testing Instructions
Setup
course-v1:OpenedX+DemoX+DemoCourse.legacy_adminas Admin (legacy instructor).legacy_staffas Staff (legacy staff).tutor dev exec lms ./manage.py lms waffle_flag authz.enable_course_authoring --create --everyoneauthz_adminas Admin (AuthZ Course Admin).authz_staffas Staff (AuthZ Course Staff).Open the Course Team tab at
http://apps.local.openedx.io:8080/instructor-dashboard/<course_id>/course_team. To check responses directly, use the browser's network tab or call the endpoints:GET /api/instructor/v2/courses/<course_id>/teamGET /api/instructor/v2/courses/<course_id>/team/rolesPOST /api/instructor/v2/courses/<course_id>/teamwith{"identifiers": ["<username>"], "role": "staff", "action": "allow"}DELETE /api/instructor/v2/courses/<course_id>/team/<username>with{"roles": ["staff"]}With the flag enabled
authz_adminauthz_stafflegacy_adminlegacy_staffPrivilege escalation: as
authz_staff, try to grant yourself theinstructorrole (POST with your own username). Expect403, and the role is not assigned.With the flag disabled
Disable the flag:
tutor dev exec lms ./manage.py lms waffle_flag authz.enable_course_authoring --deactivatelegacy_adminlegacy_staffAutomated tests
tutor dev exec lms pytest lms/djangoapps/instructor/tests/test_api_v2_authz.py -k CourseTeamDeadline
Willow
AI Usage Notice
Kiro and Claude were used to help write the code and tests. A person guided the work, reviewed and corrected every change, and checked that it meets the requirements of the linked issue.