Skip to content

Commit 1e6b4e4

Browse files
committed
chore: address pr review
1 parent 31496a8 commit 1e6b4e4

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

docs/decisions/0012-glob-support-for-role-assignments.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ We will configure the ``AuthzEnforcer`` to use a domain/scope matching function
5353

5454
- The enforcer will register a domain matching function for the ``g`` (grouping) function (for example, using ``key_match_func``).
5555
- This matching function will treat ``*`` as a wildcard at the **end** of the string. That is, patterns such as ``course-v1:OpenedX+*`` will match ``course-v1:OpenedX+SOME+COURSE``, but the model will not rely on complex patterns or regular expressions.
56+
- Matching is **case-sensitive**. Scope comparisons follow exact string semantics for non-wildcard characters (for example, ``course-v1:openedx+*`` does not match ``course-v1:OpenedX+...``).
5657
- Existing ``g`` policies that use exact scopes remain valid and continue to behave identically.
5758

5859
This change allows the Casbin engine to evaluate role assignments that apply to a family of scopes instead of a single exact value, without modifying the underlying storage schema (``CasbinRule``) or the overall request format (``r = sub, act, scope``).
@@ -70,9 +71,22 @@ The following rules apply initially:
7071
- The glob character (``*``) is only supported as a **suffix wildcard**. It cannot appear in the middle of a scope identifier.
7172
- A glob pattern represents a **bounded prefix match** for the external key portion of a scope within its namespace. The API validation ensures the prefix is meaningful (i.e., it corresponds to a valid identifier boundary for that namespace), so the glob cannot be used to accidentally broaden access.
7273
- For any glob patterns (courses, libraries, or future namespaces), malformed inputs (such as mid-string wildcards or prefixes that do not match the expected key format/boundaries) are **rejected**.
73-
- Additional namespaces must define their own, explicit validation rules before accepting glob scopes.
74+
- Additional namespaces must define their own, explicit validation rules before accepting glob scopes. If a namespace does not have a custom matcher/validator, any ``*`` in its scope is rejected and only exact scopes are accepted.
7475
- As needs evolve, more glob types can be added safely by introducing namespace-specific semantics and validations (for example, additional prefix boundaries such as program/tenant prefixes, or narrower matching strategies if required).
7576

77+
Examples of valid/invalid namespace scope globs
78+
-----------------------------------------------
79+
80+
Given the current suffix-glob policy (single trailing ``*`` at a namespace-approved boundary):
81+
82+
- Invalid: ``*`` (unbounded across all namespaces/scopes).
83+
- Invalid: ``c*`` or ``l*`` (not a valid namespaced scope prefix).
84+
- Invalid: ``course-v1*`` or ``lib*`` (missing ``:`` and required namespace structure).
85+
- Invalid: ``course-v1:*`` or ``lib:*`` (wildcard starts before a bounded prefix inside the ``course-v1`` or ``lib`` key).
86+
- Invalid: ``course-v1:O*`` or ``lib:MIT*`` (wildcard starts mid-segment. Prefix boundary is not complete).
87+
- Valid: ``course-v1:OpenedX+*`` (wildcard starts at an approved boundary for the ``course-v1`` namespace).
88+
- Valid: ``lib:MITx:*`` (wildcard starts at an approved boundary for the ``lib`` namespace).
89+
7690
These validation rules are implemented in the Open edX layer (API / data layer), not in the Casbin matcher itself. The enforcer remains general-purpose. The domain-specific semantics of what constitutes an acceptable glob pattern are enforced at the boundary where user/operator input is turned into policies.
7791

7892
3. Keep the model general and extensible

0 commit comments

Comments
 (0)