Skip to content

Commit d666e35

Browse files
docs: update inline doc with better structure
1 parent 78cdd84 commit d666e35

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

openedx_authz/api/decorators.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from django.conf import settings
55

6-
from openedx_authz.api.data import ScopeData
76
from openedx_authz.engine.enforcer import enforcer
87
from openedx_authz.engine.filter import Filter
98

@@ -38,18 +37,21 @@ def get_roles_in_scope(scope: ScopeData):
3837
return enforcer.get_filtered_roles(scope.namespaced_key)
3938
"""
4039

41-
FILTER_DATA_CLASSES = { # Consider empty for no filtering
40+
FILTER_DATA_CLASSES = { # Consider empty for no filtering
4241
# "scope": ScopeData,
43-
# TODO: currently ALLOW_FILTERED_POLICY_LOADING is False to avoid partial policy loads. We can
44-
# Allow filtering on scope (initially) once we have a CONF model that supports this so filtering is meaningful,
45-
# consistent and doesn't lead to partial policy loads.
46-
# We can consider this modeling to avoid partial loads and inconsistent states:
47-
# 1. g only for user-role-scope bindings
48-
# 2. p only for permission-role bindings
49-
# 3. g2 only for role-role bindings
50-
# 4. g3 only for permission grouping
51-
# This way for a user we'd only need to load g ( filter only for the scope or user) , p, g2, g3 policies in
52-
# each request. The only filter binding would be g, the rest loads entirely to avoid not loading definitions.
42+
# TODO: Currently, ALLOW_FILTERED_POLICY_LOADING is set to False to prevent partial policy loads,
43+
# so this dictionary is also intentionally left empty.
44+
# We can enable scope-based filtering once we have a CONF model that supports it,
45+
# ensuring the filtering is meaningful, consistent, and does not cause partial policy loads.
46+
#
47+
# One possible model to support safe filtering and avoid inconsistent states could be:
48+
# 1. g -> user-role-scope bindings
49+
# 2. p -> permission-role bindings
50+
# 3. g2 -> role-role bindings
51+
# 4. g3 -> permission grouping
52+
#
53+
# With this structure, for a given user we would only need to load g (filtered by scope or user),
54+
# while p, g2, and g3 would be fully loaded to ensure all definitions are available.
5355
}
5456

5557
def build_filter_from_args(args) -> Filter:

0 commit comments

Comments
 (0)