Casbin Forum runs on Casnode, the open-source Discourse-style forum. Try the Casnode demo →
Casbin Forum

I want to use casbin for several projects, and all of them have the same pattern where each tenant (think company or discord server) in the app has its own admin definable permissions policy. I noticed that in the docs for model storage it says this:

Casbin models are designed to be loaded rather than saved. The model defines your access control logic and should remain static at runtime, so Casbin does not provide an API for persisting model changes to storage.
For my use case, the models are updated infrequently, but should not require an application restart. what would be the best way to approach this kind of use case?

its something like for the vast vast majority of the time, the policy won't change

4views
3users
1 minread

the policy is not the same thing as the model. The model defines what the policy means, while the policy is dynamic and rules can be added/deleted whenever.

I don't think there's much use case for having each tenant have a separate model, but there's definitely many use cases for each tenant having separate policies*

Also, if you really do need the model to change, a sub-ms latency is perfectly fine since like you said, it won't happen very often. Model changes would always happen a lot less often than policy changes I'd think

And I think the best option if you need to swap models is to have a map[key]enforcer

oh I get it now

ok thanks

I should be able to work with this

just to clarify, i meant "but there's definitely many use cases for each tenant having separate policies*"

I am a bit curious how exactly it is stored at least with a postgres back end. like does it fall apart if I start having 10 million rules in total? or maybe 1 million rules per tenant?

I can just look at it and figure it out though

1 / 9
Feb 21