pycasbin icon indicating copy to clipboard operation
pycasbin copied to clipboard

RBAC with Domain model ,get_all_subjects error

Open stonecoldyxp opened this issue 1 year ago • 3 comments

1、model.conf image 2、code: image 3、sqlite info image

question: e.get_all_objects() --> ['test.xxx.com'] it should be ['system:get','system:put','system:post']

stonecoldyxp avatar May 24 '24 04:05 stonecoldyxp

@techoner @Nekotoxin

casbin-bot avatar May 24 '24 04:05 casbin-bot

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)

leeqvip avatar May 24 '24 06:05 leeqvip

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)

case one (error): get_all_objects is not applicable to this model configuration. You can put dom at the end mdoel.conf: image sqlite info: image test result: image

stonecoldyxp avatar May 24 '24 06:05 stonecoldyxp

Oh, sorry, the order of dom cannot be changed due to hard coding.

It should be fixed as soon as possible.

leeqvip avatar May 27 '24 06:05 leeqvip

The same problem also occurs in PHP-Casbin, 🤔perhaps they can be repaired together.

Dobmod avatar Jun 09 '24 13:06 Dobmod

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 dom and is placed as the second token (sub, dom, obj, act).

The dom (domain) field is fetched when RBAC with Domains is enabled. Code references:

truc0 avatar Jun 11 '24 14:06 truc0

:tada: This issue has been resolved in version 1.36.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Jun 11 '24 16:06 github-actions[bot]