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

[Question] Advice on where to draw the border between model and policy #945

Closed
bk138 opened this issue Jan 8, 2022 · 3 comments
Closed
Assignees
Labels

Comments

@bk138
Copy link

bk138 commented Jan 8, 2022

Want to prioritize this issue? Try:

issuehunt-to-marktext


What's your scenario? What do you want to achieve?
I would love to get some advice on where to draw the border between model and policy. I have a simple RBAC model with some additional constraints modeled via the matcher. (This is all very clear, I don't need info about the matcher.) Model, policy and example requests can be seen at https://casbin.org/casbin-editor/#FNFCVSP37

Now that I have logic about my user groups in the matcher, I ask myself if the initial policy bits (lines 2 and 3 in the policy section of https://casbin.org/casbin-editor/#FNFCVSP37) are better coded in the model's matcher too as they're static anyway. https://casbin.org/casbin-editor/#CV9XS6HHF goes in that direction.

Given the two approaches a) and b), which one is more casbin-idiomatic/better any maybe why? Should Casbin models and policies written so that there is as much logic/info in the model or in the policy? I'm asking because the static initial policy bits in variant a) never change and I have to preload them to my db-backed adapter always, which creates some noticeable boilerplate.

I know this is more of an aesthetic question, but I'd like to read some comments and learn about best practices for writing Casbin models/policies.

@casbin-bot
Copy link
Member

@tangyang9464 @closetool @sagilio

@hsluoyz
Copy link
Member

hsluoyz commented Jan 9, 2022

@hsluoyz
Copy link
Member

hsluoyz commented Nov 21, 2022

@bk138 store shared logic to model, this will have better performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants