|
3 | 3 |
|
4 | 4 | from django.conf import settings |
5 | 5 |
|
6 | | -from openedx_authz.api.data import ScopeData |
7 | 6 | from openedx_authz.engine.enforcer import enforcer |
8 | 7 | from openedx_authz.engine.filter import Filter |
9 | 8 |
|
@@ -38,18 +37,21 @@ def get_roles_in_scope(scope: ScopeData): |
38 | 37 | return enforcer.get_filtered_roles(scope.namespaced_key) |
39 | 38 | """ |
40 | 39 |
|
41 | | - FILTER_DATA_CLASSES = { # Consider empty for no filtering |
| 40 | + FILTER_DATA_CLASSES = { # Consider empty for no filtering |
42 | 41 | # "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. |
53 | 55 | } |
54 | 56 |
|
55 | 57 | def build_filter_from_args(args) -> Filter: |
|
0 commit comments