You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Task - RBAC AuthZ - Multi scope roles: Implement support for glob permissions and validations #172
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).
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
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.
Activity
rodmgwgu commentedon Mar 10, 2026
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
mariajgrimaldi commentedon Mar 11, 2026
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-R31I’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.