Skip to content

Backend permission enforcement (LMS) #485

Open
10 of 12 issues completed
Open

Description

@BryanttV

Enforce the new permissions in the LMS endpoints used by each Instructor Dashboard tab. The shared infrastructure (#486) comes first; the per-tab subtasks can then be worked on in parallel.

Common acceptance criteria

  • Every endpoint of the tab checks the right permission and returns 403 in the standard format (error_code: permission_denied).
  • Tests cover a user with Course Admin, one with Course Staff and one without permission.
  • Users with the equivalent legacy role and no AuthZ role keep their access.
  • The tab's visibility in CourseMetadataView matches the tab's read permissions.

Sub-issues

Sub-issues

10 of 12 Issues completed
Loading 12 sub-issues

Activity

  1. added
    willow
    on Sep 24, 2026
  2. mariajgrimaldi commented on Nov 25, 2026

    @mariajgrimaldi
    Member

    Hi! I ran the end-to-end tests for the Instructor Dashboard PRs under this issue, all merged together: #39402, #39403, #39365, #39366, #39362 and #39363 on openedx-platform, and #273 to #276 on frontend-app-instructor-dashboard. The tests are in tests/rbac/instructor-dashboard/ of my end-to-end-tests fork.

    Setup

    Results:

    Tab PRs Flag on Flag off
    Dashboard access and tabs all 14 passed, 2 skipped 20 passed
    Course Info and Enrollments #39402, #39403 21 passed, 2 different, 2 skipped 20 passed
    Course Team #39365, frontend-app-instructor-dashboard#273 22 passed, 1 different, 2 skipped 19 passed, 1 different
    Grading #39366, frontend-app-instructor-dashboard#276 17 passed, 5 different, 2 skipped 13 passed, 7 different
    Date Extensions #39362, frontend-app-instructor-dashboard#274 23 passed, 6 different, 2 skipped 12 passed, 8 different
    Cohorts #39363, frontend-app-instructor-dashboard#275 22 passed, 1 different, 2 skipped 20 passed
    Controls on every tab, flag off frontend-app-instructor-dashboard#273 to #276 12 passed
    Turning the flag on and off all 3 passed, 1 skipped
    Course Info and Enrollments (#39402, #39403)

    Differences with the flag on:

    # Role Action Got Expected
    1 Course Limited Staff (AuthZ) Course Info tab in the MFE Access Denied alert Course Info summary
    2 Course Data Researcher (AuthZ) Course Info tab in the MFE Access Denied alert Course Info summary

    These two tests check the Course Info tab first and stop at the first difference, so they didn't reach the Enrollments tab controls.

    Why these were expected:

    • With the flag on, Course Limited Staff (AuthZ) and Course Data Researcher (AuthZ) keep the access of their legacy role (compat.py), and their API tests for this tab passed.
    Tests with the flag on

    The roles whose expected results for this tab change when the flag turns on, and the tests with a different result.

    # Test Result
    1 Admin (legacy), not migrated: Course Info and Enrollments actions through the API skipped (manual mode)
    2 Staff (legacy), not migrated: Course Info and Enrollments actions through the API skipped (manual mode)
    3 Course Limited Staff (AuthZ): Course Info and Enrollments tab controls in the MFE different
    4 Course Data Researcher (AuthZ): Course Info and Enrollments tab controls in the MFE different
    Course Team (#39365, frontend-app-instructor-dashboard#273)

    Differences with the flag on:

    # Role Action Got Expected
    1 Discussion Admin (legacy) migrated to Course Staff (AuthZ) add and remove a forum role 403 with error_code: permission_denied 2xx

    Why these were expected:

    • openedx-authz#376 expects that "Legacy role behavior is preserved unless explicitly changed", and with the flag off the Discussion Admin (legacy) test adds and removes forum roles.

    Differences with the flag off:

    # Role Action Got Expected
    1 Discussion Admin (legacy) add and remove a member with a course role 403 without error_code 403 with error_code: permission_denied

    Why these were expected:

    • This issue asks every endpoint of a tab to return 403 in the standard format, error_code: permission_denied.
    Tests with the flag on

    The roles whose expected results for this tab change when the flag turns on, and the tests with a different result.

    # Test Result
    1 Course Staff (AuthZ): Course Team actions through the API passed
    2 org-wide Course Staff (AuthZ): Course Team actions through the API passed
    3 Discussion Admin (legacy) migrated to Course Staff (AuthZ): Course Team actions through the API passed
    4 Course Editor (AuthZ): Course Team actions through the API passed
    5 Course Auditor (AuthZ): Course Team actions through the API passed
    6 Admin (legacy), not migrated: Course Team actions through the API skipped (manual mode)
    7 Staff (legacy), not migrated: Course Team actions through the API skipped (manual mode)
    8 Course Staff (AuthZ) cannot give themselves the instructor role passed
    9 Discussion Admin (legacy) migrated to Course Staff (AuthZ) adds and removes forum roles different
    10 Course Staff (AuthZ): Course Team tab controls in the MFE passed
    11 org-wide Course Staff (AuthZ): Course Team tab controls in the MFE passed
    12 Discussion Admin (legacy) migrated to Course Staff (AuthZ): Course Team tab controls in the MFE passed
    13 Course Editor (AuthZ): Course Team tab controls in the MFE passed
    14 Course Auditor (AuthZ): Course Team tab controls in the MFE passed
    Grading (#39366, frontend-app-instructor-dashboard#276)

    Differences with the flag on:

    # Role Action Got Expected
    1 Course Staff (AuthZ) v1 reset_student_attempts with delete_module 2xx 403
    2 org-wide Course Staff (AuthZ) v1 reset_student_attempts with delete_module 2xx 403
    3 Discussion Admin (legacy) migrated to Course Staff (AuthZ) v1 reset_student_attempts with delete_module 2xx 403
    4 Course Limited Staff (AuthZ) All Learners reset and rescore 403 without error_code 403 with error_code: permission_denied
    v1 reset_student_attempts with delete_module 2xx 403
    5 Course Limited Staff (AuthZ) Grading tab in the MFE Access Denied alert Grading controls

    Why these were expected:

    • Rows 1 to 4, v1 delete state: reset_student_attempts documents delete_module as needing instructor access (api.py).
    • Row 4, All Learners: this issue asks every endpoint of a tab to return 403 in the standard format, error_code: permission_denied.
    • Row 5: With the flag on, Course Limited Staff (AuthZ) keeps the access of its legacy role (compat.py), and its API tests for this tab passed.

    Differences with the flag off:

    Staff (legacy), Org Staff (legacy), Discussion Admin (legacy), Limited Staff (legacy), and Course Staff (AuthZ), org-wide Course Staff (AuthZ) and Course Limited Staff (AuthZ) assigned while the flag is off, got the same two differences (7 tests).

    Action Got Expected
    All Learners reset and rescore 403 without error_code 403 with error_code: permission_denied
    v1 reset_student_attempts with delete_module 2xx 403

    Why these were expected:

    • All Learners: this issue asks every endpoint of a tab to return 403 in the standard format, error_code: permission_denied.
    • v1 delete state: reset_student_attempts documents delete_module as needing instructor access (api.py).
    Tests with the flag on

    The roles whose expected results for this tab change when the flag turns on, and the tests with a different result.

    # Test Result
    1 Course Staff (AuthZ): learner search and Grading actions through the API different
    2 org-wide Course Staff (AuthZ): learner search and Grading actions through the API different
    3 Discussion Admin (legacy) migrated to Course Staff (AuthZ): learner search and Grading actions through the API different
    4 Course Editor (AuthZ): learner search and Grading actions through the API passed
    5 Course Auditor (AuthZ): learner search and Grading actions through the API passed
    6 Course Limited Staff (AuthZ): learner search and Grading actions through the API different
    7 Admin (legacy), not migrated: learner search and Grading actions through the API skipped (manual mode)
    8 Staff (legacy), not migrated: learner search and Grading actions through the API skipped (manual mode)
    9 Course Staff (AuthZ): Grading tab controls in the MFE passed
    10 org-wide Course Staff (AuthZ): Grading tab controls in the MFE passed
    11 Discussion Admin (legacy) migrated to Course Staff (AuthZ): Grading tab controls in the MFE passed
    12 Course Editor (AuthZ): Grading tab controls in the MFE passed
    13 Course Auditor (AuthZ): Grading tab controls in the MFE passed
    14 Course Limited Staff (AuthZ): Grading tab controls in the MFE different
    Date Extensions (#39362, frontend-app-instructor-dashboard#274)

    Differences with the flag on:

    # Role Action Got Expected
    1 Course Editor (AuthZ) list, grant and reset extensions 403 without error_code 403 with error_code: permission_denied
    2 Course Auditor (AuthZ) list, grant and reset extensions 403 without error_code 403 with error_code: permission_denied
    3 Course Beta Tester (AuthZ) list, grant and reset extensions 403 without error_code 403 with error_code: permission_denied
    4 CCX Coach (legacy) migrated to CCX Coach (AuthZ) list, grant and reset extensions 403 without error_code 403 with error_code: permission_denied
    5 Learner (enrolled, no role) list, grant and reset extensions 403 without error_code 403 with error_code: permission_denied
    6 Course Data Researcher (AuthZ) learner search and list extensions 2xx 403 with error_code: permission_denied
    grant and reset extensions 403 without error_code 403 with error_code: permission_denied

    Why these were expected:

    • Denials without error_code: this issue asks every endpoint of a tab to return 403 in the standard format, error_code: permission_denied.
    • Row 6, learner search and list: The legacy rule for extensions needs the staff access level (permissions.py), which Data Researcher doesn't have, and Course Data Researcher keeps its legacy access with the flag on (compat.py).

    Differences with the flag off:

    # Role Action Got Expected
    1 Data Researcher (legacy) learner search and list extensions 2xx 403 with error_code: permission_denied
    grant and reset extensions 403 without error_code 403 with error_code: permission_denied
    2 Course Data Researcher (AuthZ), assigned while the flag is off learner search and list extensions 2xx 403 with error_code: permission_denied
    grant and reset extensions 403 without error_code 403 with error_code: permission_denied
    3 Beta Tester (legacy) list, grant and reset extensions 403 without error_code 403 with error_code: permission_denied
    4 Course Beta Tester (AuthZ), assigned while the flag is off list, grant and reset extensions 403 without error_code 403 with error_code: permission_denied
    5 Course Editor (AuthZ), assigned while the flag is off list, grant and reset extensions 403 without error_code 403 with error_code: permission_denied
    6 Course Auditor (AuthZ), assigned while the flag is off list, grant and reset extensions 403 without error_code 403 with error_code: permission_denied
    7 CCX Coach (legacy) list, grant and reset extensions 403 without error_code 403 with error_code: permission_denied
    8 Learner (enrolled, no role) list, grant and reset extensions 403 without error_code 403 with error_code: permission_denied

    Why these were expected:

    • Denials without error_code: this issue asks every endpoint of a tab to return 403 in the standard format, error_code: permission_denied.
    • Rows 1 and 2, learner search and list: The legacy rule for extensions needs the staff access level (permissions.py), which Data Researcher doesn't have, and Course Data Researcher keeps its legacy access with the flag on (compat.py).
    Tests with the flag on

    The roles whose expected results for this tab change when the flag turns on, and the tests with a different result.

    # Test Result
    1 Course Staff (AuthZ): learner search and Date Extensions actions through the API passed
    2 org-wide Course Staff (AuthZ): learner search and Date Extensions actions through the API passed
    3 Discussion Admin (legacy) migrated to Course Staff (AuthZ): learner search and Date Extensions actions through the API passed
    4 Course Editor (AuthZ): learner search and Date Extensions actions through the API different
    5 Course Auditor (AuthZ): learner search and Date Extensions actions through the API different
    6 Course Data Researcher (AuthZ): learner search and Date Extensions actions through the API different
    7 Course Beta Tester (AuthZ): learner search and Date Extensions actions through the API different
    8 CCX Coach (legacy) migrated to CCX Coach (AuthZ): learner search and Date Extensions actions through the API different
    9 Admin (legacy), not migrated: learner search and Date Extensions actions through the API skipped (manual mode)
    10 Staff (legacy), not migrated: learner search and Date Extensions actions through the API skipped (manual mode)
    11 Learner (enrolled, no role): learner search and Date Extensions actions through the API different
    12 Course Staff (AuthZ): Date Extensions tab controls in the MFE passed
    13 org-wide Course Staff (AuthZ): Date Extensions tab controls in the MFE passed
    14 Discussion Admin (legacy) migrated to Course Staff (AuthZ): Date Extensions tab controls in the MFE passed
    15 Course Staff (AuthZ): grants and resets an extension from the Date Extensions tab passed
    16 org-wide Course Staff (AuthZ): grants and resets an extension from the Date Extensions tab passed
    17 Discussion Admin (legacy) migrated to Course Staff (AuthZ): grants and resets an extension from the Date Extensions tab passed
    Cohorts (#39363, frontend-app-instructor-dashboard#275)

    Differences with the flag on:

    # Role Action Got Expected
    1 Course Limited Staff (AuthZ) Cohorts tab in the MFE Access Denied alert Cohorts controls

    Why these were expected:

    • With the flag on, Course Limited Staff (AuthZ) keeps the access of its legacy role (compat.py), and its API tests for this tab passed.
    Tests with the flag on

    The roles whose expected results for this tab change when the flag turns on, and the tests with a different result.

    # Test Result
    1 Course Admin (AuthZ): cohort actions through the API, the Studio cohort settings and the CSV upload passed
    2 org-wide Course Admin (AuthZ): cohort actions through the API, the Studio cohort settings and the CSV upload passed
    3 Course Staff (AuthZ): cohort actions through the API, the Studio cohort settings and the CSV upload passed
    4 org-wide Course Staff (AuthZ): cohort actions through the API, the Studio cohort settings and the CSV upload passed
    5 Discussion Admin (legacy) migrated to Course Staff (AuthZ): cohort actions through the API, the Studio cohort settings and the CSV upload passed
    6 Admin (legacy), not migrated: cohort actions through the API, the Studio cohort settings and the CSV upload skipped (manual mode)
    7 Staff (legacy), not migrated: cohort actions through the API, the Studio cohort settings and the CSV upload skipped (manual mode)
    8 Course Admin (AuthZ): Cohorts tab controls in the MFE passed
    9 org-wide Course Admin (AuthZ): Cohorts tab controls in the MFE passed
    10 Course Staff (AuthZ): Cohorts tab controls in the MFE passed
    11 org-wide Course Staff (AuthZ): Cohorts tab controls in the MFE passed
    12 Discussion Admin (legacy) migrated to Course Staff (AuthZ): Cohorts tab controls in the MFE passed
    13 Course Limited Staff (AuthZ): Cohorts tab controls in the MFE different
    How to run the tests
    1. Start a Tutor main dev stack (with tutor-mfe, tutor-forum and tutor-notes from main) with the openedx-platform and MFE branches mounted:
    git clone -b MJG/e2e-instructor-dashboard https://github.com/mariajgrimaldi/edx-platform.git openedx-platform
    git clone -b MJG/e2e-instructor-dashboard-permissions https://github.com/mariajgrimaldi/frontend-app-instructor-dashboard.git
    git clone -b MJG/authz-instructor-dashboard-e2e https://github.com/mariajgrimaldi/end-to-end-tests.git
    tutor mounts add ./openedx-platform
    tutor mounts add ./frontend-app-instructor-dashboard
    cp end-to-end-tests/.ci/tutor/e2e_base.py "$(tutor plugins printroot)/"
    cat > "$(tutor plugins printroot)/e2e_entrance_exams.py" <<'EOF'
    from tutor import hooks
    hooks.Filters.ENV_PATCHES.add_item(("openedx-common-settings", "ENTRANCE_EXAMS = True"))
    EOF
    tutor plugins enable mfe forum notes e2e_base e2e_entrance_exams
    tutor images build openedx-dev mfe-dev
    tutor dev launch --non-interactive
    tutor dev do importdemocourse
    tutor dev do createuser --staff --superuser <admin> <email>
    1. Set up the tests:
    cd end-to-end-tests && npm install && npm run install:browsers && cp .env.example .env

    In .env:

    LMS_BASE_URL=http://local.openedx.io:8000
    CMS_BASE_URL=http://studio.local.openedx.io:8001
    APPS_BASE_URL=http://apps.local.openedx.io:8080
    INSTRUCTOR_DASHBOARD_MFE_URL=http://apps.local.openedx.io:8080/instructor-dashboard
    ADMIN_USERNAME=<admin>
    ADMIN_PASSWORD=<password>
    COURSE_KEY=course-v1:OpenedX+DemoX+DemoCourse
    CAPABILITIES=studio,cohorts,rbac,authz-auto-migration
    WORKERS=1

    With more than one worker, course creation deadlocks MySQL on tutor dev.

    1. Run the specs, one per line:
    npx playwright test tests/rbac/instructor-dashboard/access.spec.ts
    npx playwright test tests/rbac/instructor-dashboard/course-info-enrollments.spec.ts
    npx playwright test tests/rbac/instructor-dashboard/course-team.spec.ts
    npx playwright test tests/rbac/instructor-dashboard/grading.spec.ts
    npx playwright test tests/rbac/instructor-dashboard/date-extensions.spec.ts
    npx playwright test tests/rbac/instructor-dashboard/cohorts.spec.ts
    npx playwright test tests/rbac/instructor-dashboard/legacy-controls.spec.ts
    npx playwright test tests/rbac/instructor-dashboard/flag-changes.spec.ts

    The whole suite takes about 3 hours, and each spec can run on its own.

    In short:

    • With the flag on:
      • The MFE shows Access Denied to Course Limited Staff (AuthZ) on Course Info, Grading and Cohorts, and to Course Data Researcher (AuthZ) on Course Info, while their API tests for those tabs passed.
      • On Date Extensions, Course Editor, Course Auditor, Course Beta Tester, the migrated CCX Coach and the learner get the list, grant and reset denials without error_code.
      • Course Data Researcher (AuthZ) can search learners and list extensions, and gets the grant and reset denials without error_code.
      • The Discussion Admin (legacy) migrated to Course Staff (AuthZ) gets 403 when adding or removing a forum role.
      • Course Limited Staff (AuthZ) gets the All Learners reset and rescore denials without error_code.
      • Course Staff (AuthZ), org-wide Course Staff (AuthZ), the migrated Discussion Admin and Course Limited Staff (AuthZ) can delete a learner's state through the v1 reset_student_attempts.
    • With the flag off:
      • On Date Extensions, 8 roles get denials without error_code, and Data Researcher (legacy) and Course Data Researcher (AuthZ) can search learners and list extensions.
      • On Grading, 7 roles get the All Learners denials without error_code and can delete a learner's state through the v1 reset_student_attempts.
      • Discussion Admin (legacy) gets 403 without error_code when adding or removing a course team member.
    • The manual-mode tests were skipped, because the stack ran the automatic migration only.
    • The Enrollments tab controls weren't checked for Course Limited Staff (AuthZ) and Course Data Researcher (AuthZ), because their test checks the Course Info tab first and stops at its difference.

    If any of these look wrong, please let me know!

  3. BryanttV commented on Nov 27, 2026

    @BryanttV
    ContributorAuthor

    Thanks, @mariajgrimaldi. I'll reply to the report summary:

    With the flag on:

    • Bullet 1: The Course Limited Staff and Course Data Researcher (AuthZ) roles will get the corresponding permissions for the tabs they can view (more context here). I'll be working on the changes in openedx-authz.
    • Bullet 2, 3, and 5: Views that don't inherit from DeveloperErrorViewMixin yet should do so, so that error_code is returned in the response.
    • Bullet 3: The behavior does happen, but it's not an AuthZ regression: Data Researcher behaves the same with the legacy role and with AuthZ. If we want to restrict that role from accessing those two endpoints, it should be fixed in the legacy validation.
    • Bullet 4: The Discussion Admin role doesn't have an AuthZ equivalent, so this broken behavior wouldn't apply. Also, forum endpoints aren't being considered for the migration either.
    • Bullet 6: The ResetStudentAttempts view wasn't migrated, since the Instructor Dashboard MFE doesn't use it. The behavior stays as it is right now. If we want to modify the legacy validation to match API v2, that should be a separate change.

    With the flag off:

    • Bullet 1: What's related to the Data Researcher role (Legacy and AuthZ) is the same as Bullet 3 (flag on).
    • Bullet 2: The ResetStudentAttempts view wasn't migrated, since the Instructor Dashboard MFE doesn't use it. The behavior stays as it is right now.
    • Bullet 1, 2, and 3: Views that don't inherit from DeveloperErrorViewMixin yet should do so, so that error_code is returned in the response.

    The necessary changes will be worked on in each of the PRs, as well as in openedx-authz.

  4. mariajgrimaldi commented on Nov 30, 2026

    @mariajgrimaldi
    Member

    Thanks so much @BryanttV! I'm going to adapt the test cases according to your review, thanks!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    willow

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions