Skip to content

Task - RBAC AuthZ - Add Scope-Type Filtering to get_scopes_for_user_and_permission #246

Closed

Description

@dwong2708

Description

Currently, get_scopes_for_user_and_permission may return a mix of scope types (e.g., CourseOverviewData, OrgCourseOverviewGlobData, and potentially others).

In downstream consumers, we are repeatedly applying additional filtering logic to handle only the relevant scope types (e.g., course-level scopes). This pattern introduces:

  • Duplicate filtering logic across multiple code paths
  • Increased risk of edge cases or inconsistencies
  • Reduced clarity on what the API is expected to return

There is also an upcoming need to handle organization-level scopes separately, which further highlights the importance of clearly separating scope types.

Problem

The current API does not provide a way to filter results by scope type, forcing consumers to:

Be aware of all possible scope types
Implement their own filtering logic
Potentially miss new or unexpected scope types

Proposed Solution

Enhance the get_scopes_for_user_and_permission API to support filtering by scope type.

For example, introduce an optional parameter:

get_scopes_for_user_and_permission(
    username,
    permission,
    scope_types: Optional[List[str]] = None
)

Where scope_types could include values such as:

  • "course"
  • "course_glob"
  • "organization" (future use)

The API would then return only scopes matching the requested types.

Activity

  1. rodmgwgu commented on Apr 8, 2026

    @rodmgwgu
    Contributor

    Moved this to M2 as it's an improvement not strictly needed for M1

  2. self-assigned this
    on Apr 9, 2026
  3. dwong2708 commented on Apr 13, 2026

    @dwong2708
    ContributorAuthor

    After further analysis and implementing the change, I concluded that it is no longer needed.

    Reason:

    At the time this ticket was created, the Organization-based approach was not yet implemented in the course list process. Now that it is in place, there is no need to add scope filtering.
    When calling get_scopes_for_user_and_permission, we require all scopes returned by the function. For reference, this is where all scopes are used:
    https://github.com/openedx/openedx-platform/pull/38307/changes#diff-937adee5129f53ead6b3c7c988d70db9e9e95862f17a6f85a1eea2388d12b461R834

    However, I’ve created a draft PR in case this functionality is needed in the future:
    #258

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