Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RBAC with Domain model ,get_all_subjects error #345

Closed
stonecoldyxp opened this issue May 24, 2024 · 7 comments · Fixed by #346
Closed

RBAC with Domain model ,get_all_subjects error #345

stonecoldyxp opened this issue May 24, 2024 · 7 comments · Fixed by #346
Assignees
Labels
bug Something isn't working released

Comments

@stonecoldyxp
Copy link

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']

@casbin-bot
Copy link
Member

@techoner @Nekotoxin

@casbin-bot casbin-bot added the bug Something isn't working label May 24, 2024
@leeqvip
Copy link
Member

leeqvip commented May 24, 2024

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)

@stonecoldyxp
Copy link
Author

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

@leeqvip
Copy link
Member

leeqvip commented May 27, 2024

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

It should be fixed as soon as possible.

@Dobmod
Copy link

Dobmod commented Jun 9, 2024

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

@truc0
Copy link
Contributor

truc0 commented Jun 11, 2024

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:

leeqvip pushed a commit that referenced this issue Jun 11, 2024
* fix: field_index is incorrect in RBAC with domains mode (#345)

* chore: replace field name with constant in ManagementEnforcer
github-actions bot pushed a commit that referenced this issue Jun 11, 2024
## [1.36.2](v1.36.1...v1.36.2) (2024-06-11)

### Bug Fixes

* field_index is incorrect in RBAC with domains mode ([#345](#345)) ([#346](#346)) ([9f6a379](9f6a379))
Copy link

🎉 This issue has been resolved in version 1.36.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
Development

Successfully merging a pull request may close this issue.

6 participants