Repository navigation
Description
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
- Enable
grades.writable_gradebookfor a course. - Create a user without global staff access or course-level roles.
- Assign the user the AuthZ role
course_stafffor every course of the course's organization (scopecourse-v1:<org>+*). - Log in as that user and request
GET /api/grades/v1/gradebook/<course_id>/grading-info. It is expected to return200. - Open the Gradebook MFE for the same course.
- 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_stafforsupportrole 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_staffistrue.- An entry has one of the allowed roles, and either:
- its
course_idis the current course (current behavior), or - its
course_idis"None"and itsorgis the organization of the current course (new).
- its
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))
);courseOrgis the organization taken from the course key, for exampleOpenedXincourse-v1:OpenedX+DemoX+DemoCourse."None"is a string in the response, notnull.- 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_staffandcourse_admin): the roles API returned only entries withcourse_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.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn Review
Activity