Skip to content

feat: enforce AuthZ permissions in the Course Team endpoints - #39365

Open
carlos-marquez-wgu wants to merge 1 commit into
openedx:masterfrom
WGU-Open-edX:carlos-marquez-wgu/issue-489-authz-instructor-dashboard-enforcement_course-team-tab-2
Open

carlos-marquez-wgu wants to merge 1 commit into
openedx:masterfrom
WGU-Open-edX:carlos-marquez-wgu/issue-489-authz-instructor-dashboard-enforcement_course-team-tab-2

Conversation

@carlos-marquez-wgu

@carlos-marquez-wgu carlos-marquez-wgu commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Description

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

The behavior follows the authz.enable_course_authoring waffle flag, as introduced in #39255:

  • Flag enabled for the course: only AuthZ is consulted, except for the legacy roles that openedx-authz maps without dashboard permissions (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.
  • Flag disabled: the legacy rule applies (instructor, or staff plus the forum Administrator role), so existing users keep their access.

Affected roles: Course Admin, Course Staff, legacy course instructors and Discussion Admins.

Supporting Information

Testing Instructions

Setup

  1. Pick a course, for example course-v1:OpenedX+DemoX+DemoCourse.
  2. With the flag disabled, open Studio > Settings > Course Team and add:
    • legacy_admin as Admin (legacy instructor).
    • legacy_staff as Staff (legacy staff).
  3. Enable the flag:
    tutor dev exec lms ./manage.py lms waffle_flag authz.enable_course_authoring --create --everyone
  4. With the flag enabled, add in Studio > Settings > Roles and Permissions and assign:
    • authz_admin as Admin (AuthZ Course Admin).
    • authz_staff as 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>/team
  • GET /api/instructor/v2/courses/<course_id>/team/roles
  • POST /api/instructor/v2/courses/<course_id>/team with {"identifiers": ["<username>"], "role": "staff", "action": "allow"}
  • DELETE /api/instructor/v2/courses/<course_id>/team/<username> with {"roles": ["staff"]}

With the flag enabled

User Course Team tab List members and roles Add or remove a member
authz_admin Shown 200 200
authz_staff Shown 200 403
legacy_admin Hidden (no access to the dashboard) 403 403
legacy_staff Hidden (no access to the dashboard) 403 403

Privilege escalation: as authz_staff, try to grant yourself the instructor role (POST with your own username). Expect 403, 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 --deactivate
User Course Team tab List members and roles Add or remove a member
legacy_admin Shown 200 200
legacy_staff Hidden 403 403

Automated tests

tutor dev exec lms pytest lms/djangoapps/instructor/tests/test_api_v2_authz.py -k CourseTeam

Deadline

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.

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
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Nov 11, 2026
@openedx-webhooks

openedx-webhooks commented Nov 11, 2026 •

Copy link
Copy Markdown

Thanks for the pull request, @carlos-marquez-wgu!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform-oncall.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Nov 11, 2026
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in Contributions Nov 11, 2026
@carlos-marquez-wgu
carlos-marquez-wgu marked this pull request as ready for review November 12, 2026 16:10
@carlos-marquez-wgu

Copy link
Copy Markdown
Contributor Author

Hi @openedx/wg-maintenance-openedx-platform-oncall, this PR is ready for reviews, thanks!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Enforcement: Course Team tab

3 participants