Repository: casbin/pycasbin

Issue:
RBAC with Domain model ,get_all_subjects error
1、model.conf
![image](https://github.com/casbin/pycasbin/assets/32121721/9cd37638-a702-4138-8544-50fbdaa0e55f)
2、code：
![image](https://github.com/casbin/pycasbin/assets/32121721/5041e3a1-af32-41a5-8895-227289c759b2)
3、sqlite info
![image](https://github.com/casbin/pycasbin/assets/32121721/f66c78a6-a64c-43fe-9985-e18edde72b65)

question:
e.get_all_objects()  --> ['test.xxx.com']
it should be ['system:get','system:put','system:post']

Discussion:
casbin-bot:  @Nekotoxin please review
CLAassistant: [![CLA assistant check](https://cla-assistant.io/pull/badge/not_signed)](https://cla-assistant.io/casbin/pycasbin?pullRequest=346) <br/>Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our [Contributor License Agreement](https://cla-assistant.io/casbin/pycasbin?pullRequest=346) before we can accept your contribution.<br/><sub>You have signed the CLA already but the status is still pending? Let us [recheck](https://cla-assistant.io/check/casbin/pycasbin?pullRequest=346) it.</sub>
hsluoyz: @leeqvip plz review

Patch:
diff --git a/casbin/constant/constants.py b/casbin/constant/constants.py
index c5b89b3..428dc13 100644
--- a/casbin/constant/constants.py
+++ b/casbin/constant/constants.py
@@ -13,6 +13,7 @@
 # limitations under the License.
 
 # Index constants
+ACTION_INDEX = "act"
 DOMAIN_INDEX = "dom"
 SUBJECT_INDEX = "sub"
 OBJECT_INDEX = "obj"
diff --git a/casbin/management_enforcer.py b/casbin/management_enforcer.py
index b374ce1..b1897fa 100644
--- a/casbin/management_enforcer.py
+++ b/casbin/management_enforcer.py
@@ -14,6 +14,7 @@
 
 from casbin.internal_enforcer import InternalEnforcer
 from casbin.model.policy_op import PolicyOp
+from casbin.constant.constants import ACTION_INDEX, SUBJECT_INDEX, OBJECT_INDEX
 
 
 class ManagementEnforcer(InternalEnforcer):
@@ -27,7 +28,8 @@ class ManagementEnforcer(InternalEnforcer):
 
     def get_all_named_subjects(self, ptype):
         """gets the list of subjects that show up in the current named policy."""
-        return self.model.get_values_for_field_in_policy("p", ptype, 0)
+        field_index = self.model.get_field_index(ptype, SUBJECT_INDEX)
+        return self.model.get_values_for_field_in_policy("p", ptype, field_index)
 
     def get_all_objects(self):
         """gets the list of objects that show up in the current policy."""
@@ -35,7 +37,8 @@ class ManagementEnforcer(InternalEnforcer):
 
     def get_all_named_objects(self, ptype):
         """gets the list of objects that show up in the current named policy."""
-        return self.model.get_values_for_field_in_policy("p", ptype, 1)
+        field_index = self.model.get_field_index(ptype, OBJECT_INDEX)
+        return self.model.get_values_for_field_in_policy("p", ptype, field_index)
 
     def get_all_actions(self):
         """gets the list of actions that show up in the current policy."""
@@ -43,7 +46,8 @@ class ManagementEnforcer(InternalEnforcer):
 
     def get_all_named_actions(self, ptype):
         """gets the list of actions that show up in the current named policy."""
-        return self.model.get_values_for_field_in_policy("p", ptype, 2)
+        field_index = self.model.get_field_index(ptype, ACTION_INDEX)
+        return self.model.get_values_for_field_in_policy("p", ptype, field_index)
 
     def get_all_roles(self):
         """gets the list of roles that show up in the current named policy."""


Test patch:
diff --git a/tests/test_management_api.py b/tests/test_management_api.py
index 84f5522..e924daa 100644
--- a/tests/test_management_api.py
+++ b/tests/test_management_api.py
@@ -38,6 +38,18 @@ class TestManagementApi(TestCaseBase):
         self.assertEqual(e.get_all_actions(), ["read", "write"])
         self.assertEqual(e.get_all_roles(), ["data2_admin"])
 
+    def test_get_list_with_domains(self):
+        e = self.get_enforcer(
+            get_examples("rbac_with_domains_model.conf"),
+            get_examples("rbac_with_domains_policy.csv"),
+            # True,
+        )
+
+        self.assertEqual(e.get_all_subjects(), ["admin"])
+        self.assertEqual(e.get_all_objects(), ["data1", "data2"])
+        self.assertEqual(e.get_all_actions(), ["read", "write"])
+        self.assertEqual(e.get_all_roles(), ["admin"])
+
     def test_get_policy_api(self):
         e = self.get_enforcer(
             get_examples("rbac_model.conf"),