14
14
15
15
from casbin .internal_enforcer import InternalEnforcer
16
16
from casbin .model .policy_op import PolicyOp
17
+ from casbin .constant .constants import ACTION_INDEX , SUBJECT_INDEX , OBJECT_INDEX
17
18
18
19
19
20
class ManagementEnforcer (InternalEnforcer ):
@@ -27,7 +28,7 @@ def get_all_subjects(self):
27
28
28
29
def get_all_named_subjects (self , ptype ):
29
30
"""gets the list of subjects that show up in the current named policy."""
30
- field_index = self .model .get_field_index (ptype , "sub" )
31
+ field_index = self .model .get_field_index (ptype , SUBJECT_INDEX )
31
32
return self .model .get_values_for_field_in_policy ("p" , ptype , field_index )
32
33
33
34
def get_all_objects (self ):
@@ -36,7 +37,7 @@ def get_all_objects(self):
36
37
37
38
def get_all_named_objects (self , ptype ):
38
39
"""gets the list of objects that show up in the current named policy."""
39
- field_index = self .model .get_field_index (ptype , "obj" )
40
+ field_index = self .model .get_field_index (ptype , OBJECT_INDEX )
40
41
return self .model .get_values_for_field_in_policy ("p" , ptype , field_index )
41
42
42
43
def get_all_actions (self ):
@@ -45,7 +46,7 @@ def get_all_actions(self):
45
46
46
47
def get_all_named_actions (self , ptype ):
47
48
"""gets the list of actions that show up in the current named policy."""
48
- field_index = self .model .get_field_index (ptype , "act" )
49
+ field_index = self .model .get_field_index (ptype , ACTION_INDEX )
49
50
return self .model .get_values_for_field_in_policy ("p" , ptype , field_index )
50
51
51
52
def get_all_roles (self ):
0 commit comments