pycasbin
pycasbin copied to clipboard
RBAC with Domain model ,get_all_subjects error
1、model.conf
2、code:
3、sqlite info
question: e.get_all_objects() --> ['test.xxx.com'] it should be ['system:get','system:put','system:post']
@techoner @Nekotoxin
get_all_objects is not applicable to this model configuration.
You can put dom at the end, or use e.get_model().get_values_for_field_in_policy("p", "p", 2)
get_all_objectsis not applicable to this model configuration. You can putdomat the end, or use e.get_model().get_values_for_field_in_policy("p", "p", 2)
case one (error):
get_all_objects is not applicable to this model configuration. You can put dom at the end
mdoel.conf:
sqlite info:
test result:
Oh, sorry, the order of dom cannot be changed due to hard coding.
It should be fixed as soon as possible.
The same problem also occurs in PHP-Casbin, 🤔perhaps they can be repaired together.
The golang version of casbin has the same problem too.
The root cause is GetAllObjects always fetch the index 1 of rules which ptype = p. However, according to the document:
Conventionally, the domain token name in policy definition is
domand is placed as the second token(sub, dom, obj, act).
The dom (domain) field is fetched when RBAC with Domains is enabled. Code references:
- Python: get_all_objects, get_all_named_objects
- PHP: getAllObjects
- Golang: GetAllObjects
:tada: This issue has been resolved in version 1.36.2 :tada:
The release is available on:
v1.36.2- GitHub release
Your semantic-release bot :package::rocket: