Skip to content

Task - RBAC AuthZ - Multi scope roles: Implement support for glob permissions and validations #172

Closed

Description

@rodmgwgu

Change the Casbin enforcer to do glob matching at the end of the string for role assignments.

Currently, the matcher in the model only supports either validating a permission to a specific scope item (lib:WGU:CSPROB), or everything in the scope that the permission supports (*, if * matches the same namespace specified in the permission definition (lib, course, org, etc.)).

This is because the “g“ (grouping) function in the Casbin model only accounts for exact matches.

This can be overcome by specifying a matching function that supports glob-like syntax, this is done by calling “enforcer.add_named_domain_matching_func("g", key_match_func)” after instantiating the enforcer in the _initialize_enforcer method on the AuthzEnforcer class in openedx-authz.

key_match_func is imported from casbin.util. It allows matching the end of a string with a “*“. See https://casbin.org/docs/function/ for details and other available matching functions.

  • Make sure that the authz APIs that are used to assign roles validate the scope string so they only allow globs after a valid org name. (don't allow things like "course-v1^course*" or "course-v1^c*", only "course-v1^course-v1:OpenedX*" or full course key).

See discussion on https://openedx.atlassian.net/wiki/spaces/OEPM/pages/5404590081/Technical+Discovery+Notes+-+AuthZ+for+Course+Authoring

Example use case:

Have a role assignation like:

g user^contributor role^course_staff course-v1^course-v1:WGU*
So, when calling:

authz_api.is_user_allowed("contributor", "courses.manage_advanced_settings", "course-v1:WGU:SOME-COURSE")

The response is True (allow)

Activity

  1. added
    verawood
    on Jan 19, 2026
  2. moved this to In Grooming in RBAC AuthZ Boardon Jan 19, 2026
  3. moved this from In Grooming to Ready for Development in RBAC AuthZ Boardon Feb 18, 2026
  4. moved this from Ready for Development to In Progress in RBAC AuthZ Boardon Mar 9, 2026
  5. rodmgwgu commented on Mar 10, 2026

    @rodmgwgu
    ContributorAuthor

    Please note: for openedx/openedx-platform#38032, we will need to have an api function that can be used to query for role assignations to orgs given a role

  6. mariajgrimaldi commented on Mar 11, 2026

    @mariajgrimaldi
    Member

    In our ADR 0005 (https://github.com/openedx/openedx-authz/pull/31/changes#r2336561623
    ) we explicitly decided not to model resource grouping using Casbin’s built-in capabilities (e,g., g). In some ways that contradicts the approach proposed here. For reference, the grouping decision was documented here: https://github.com/openedx/openedx-authz/pull/59/changes#diff-bd7ebfd51e3be0ae3779a0d934d4e462aee9bc33595a463ab80c0fbbf88c0341R29-R31

    I’m planning to drop that previous decision in favor of this new approach, which is definitely more flexible, but I think it would be useful to capture the reasoning in a dedicated ADR so the change in direction is clearly documented.

  7. moved this from In Progress to Done in RBAC AuthZ Boardon Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

verawood

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions