File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -530,20 +530,21 @@ def unassign_subject_from_all_roles(subject: SubjectData) -> bool:
530530 return enforcer .remove_filtered_grouping_policy (GroupingPolicyIndex .SUBJECT .value , subject .namespaced_key )
531531
532532
533- def get_all_role_assignments_per_scope_type (scope_type : type [ScopeData ]) -> list [RoleAssignmentData ]:
534- """Get all role assignments for a specific scope type .
533+ def get_all_role_assignments_per_scope_type (scope_types : list [ type [ScopeData ] ]) -> list [RoleAssignmentData ]:
534+ """Get all role assignments matching any of the given scope types .
535535
536536 Loads all grouping policies from the enforcer and filters in Python. Casbin policies
537537 store full scope keys (e.g., 'course-v1^course-v1:Org+Course+Run'), so there is no
538538 way to query by scope type directly so the filtering must happen here.
539539
540540 Args:
541- scope_type: A ScopeData subclass (not an instance) used to match by NAMESPACE.
541+ scope_types: A list of ScopeData subclasses (not instances). Assignments matching
542+ any of the given types are returned.
542543
543544 Returns:
544- list[RoleAssignmentData]: All assignments whose scope matches the given scope type .
545+ list[RoleAssignmentData]: All assignments whose scope is an instance of any of the given scope types .
545546 """
546547 return [
547548 role_assignment for role_assignment in get_role_assignments ()
548- if role_assignment .scope . NAMESPACE == scope_type . NAMESPACE
549+ if isinstance ( role_assignment .scope , tuple ( scope_types ))
549550 ]
Original file line number Diff line number Diff line change @@ -307,11 +307,9 @@ def migrate_authz_to_legacy_course_roles(
307307 "At least one of course_id_list or org_id must be provided to limit the scope of the rollback migration."
308308 )
309309
310- # CourseOverviewData and OrgCourseOverviewGlobData share the same NAMESPACE ("course-v1"),
311- # and get_all_role_assignments_per_scope_type matches by NAMESPACE. Passing CourseOverviewData
312- # therefore captures both course-level and org-level glob assignments. The exact scope type
313- # is narrowed per-assignment via isinstance checks in the loop below.
314- role_assignments = get_all_role_assignments_per_scope_type (scope_type = CourseOverviewData )
310+ role_assignments = get_all_role_assignments_per_scope_type (
311+ scope_types = [CourseOverviewData , OrgCourseOverviewGlobData ]
312+ )
315313
316314 # Two cases here:
317315 # 1. org_id provided: filter by org — includes org-level glob and course-level scopes for that org.
You can’t perform that action at this time.
0 commit comments