Skip to content

Allow users with org-level roles to access the Gradebook MFE #659

In review
openedx/frontend-app-gradebook
#668

Description

@BryanttV

Description

The Gradebook MFE only lets in global staff and users with a role assigned to the exact course. Users whose role covers every course of an organization see an unauthorized message, even though the Gradebook API accepts them. Platform-wide roles are affected by the same check, so org and platform-level course teams cannot use the Gradebook from the UI.

Current Behavior

The MFE calls GET /api/enrollment/v2/roles/ and grants access only if is_staff is true, or if an entry has an allowed role and a course_id equal to the current course (src/data/api.ts):

export const allowedRoles = ['staff', 'limited_staff', 'instructor', 'support'];

const isAllowedRole = (role: CourseRole) => (
  role.course_id === courseId && allowedRoles.includes(role.role)
);
return Boolean(data.is_staff || (data.roles || []).some(isAllowedRole));

Org-level roles have no course, so the API returns them with the string "None" as course_id, which never matches:

{ "org": "OpenedX", "course_id": "None", "role": "staff" }

AuthZ platform-wide roles (course-v1:*) are returned the same way, with one entry per registered organization.

As a result, the MFE shows this message and does not run the queries that depend on the check:

You are not authorized to view the gradebook for this course

Expected Behavior

The MFE grants access to users with an instructor, staff, limited_staff or support role, whether the role is assigned to the course or to its organization. This includes platform-wide roles, which the API returns per organization. Global staff keep their access, and users without any of these roles are still rejected.

Steps to reproduce

  1. Enable grades.writable_gradebook for a course.
  2. Create a user without global staff access or course-level roles.
  3. Assign the user the AuthZ role course_staff for every course of the course's organization (scope course-v1:<org>+*).
  4. Log in as that user and request GET /api/grades/v1/gradebook/<course_id>/grading-info. It is expected to return 200.
  5. Open the Gradebook MFE for the same course.
  6. Observe the unauthorized message.

Acceptance Criteria

  • The MFE still uses the enrollment roles API to decide the access.
  • A user with an organization-level instructor, staff, limited_staff or support role passes the MFE access check for the courses of that organization.
  • A user with one of these roles platform-wide passes the MFE access check for the courses of the registered organizations.
  • Users with an allowed course-level role, and global staff, keep their access.
  • A user whose only role belongs to another organization or course sees the unauthorized message.
  • A failed request to the roles API is not treated as granting access.
  • Automated tests cover course-level, organization-level, platform-wide and unauthorized users.

Proposed Solution

Keep using GET /api/enrollment/v2/roles/, and make the MFE check organization-level entries in addition to course-level ones. Access is granted if any of these is true:

  • is_staff is true.
  • An entry has one of the allowed roles, and either:
    • its course_id is the current course (current behavior), or
    • its course_id is "None" and its org is the organization of the current course (new).

The list of allowed roles does not change, and applies to both levels:

export const allowedRoles = ['staff', 'limited_staff', 'instructor', 'support'];

const isAllowedRole = (role: CourseRole) => (
  allowedRoles.includes(role.role)
  && (role.course_id === courseId || (role.course_id === 'None' && role.org === courseOrg))
);
  • courseOrg is the organization taken from the course key, for example OpenedX in course-v1:OpenedX+DemoX+DemoCourse.
  • "None" is a string in the response, not null.
  • Platform-wide roles need no extra rule, because the API returns them as one entry per registered organization.
  • The rest of the query gating does not need to change.

This keeps the change limited to the access check, but the MFE still keeps its own copy of the backend rule, which has to stay in sync with it.

Out of Scope

  • Changing the access rules of the Gradebook API.
  • Migrating the Gradebook endpoints to AuthZ permissions.
  • Changing the response of the enrollment roles API.

Notes or Additional Context

  • The problem was observed with a user holding AuthZ platform-wide roles (course_staff and course_admin): the roles API returned only entries with course_id: "None", while the backend granted access to the courses.
  • The organization-level case in the steps above is derived from the code, which returns both scopes in the same form. It has not been reproduced in the UI. By the same code path, legacy organization-level roles are expected to be affected too.

Activity

  1. moved this to Ready for Development in RBAC AuthZ Boardon Nov 26, 2026
  2. moved this from Ready for Development to Blocked in RBAC AuthZ Boardon Nov 26, 2026
  3. moved this from Blocked to Ready for Development in RBAC AuthZ Boardon Dec 1, 2026
  4. moved this from Ready for Development to Ready for Review in RBAC AuthZ Boardon Dec 2, 2026
  5. moved this from Ready for Review to In Review in RBAC AuthZ Boardon Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions