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

anyone knows how to do "Multiple Section Types" with python? https://casbin.org/docs/syntax-for-models/#multiple-section-types

basically I have a model with miltiple r (r, r2), p (p, p2) and m (m, m2), etc... by default it enforces with r,p,m... I meed to run enforcements specifying the context. Any idea how to set this with Python?

thank you, I managed to make it work at least for a good MVP: Shared at https://editor.casbin.org/#4FEZKDGSH, what do you think?

dears, anyone knows a good example of access control based on quotas? for example, create max limits of a resource by the user, a user can create up to 3 resources A and B on free quotas and up to 99 in paid quotas. In the context I have the user, the resource, the max allowed in their plan and the current count.

I can try, it syncs right? if the policies you are trying to enforce come from a synced repository of policies, the enforcement request will be consistent with the latest rules, meaning that it will load an updated (synced) list of policies, rather than not synced repo and probably loading it from an outdated one.

I see. If you don't care about higher consistency, I'd say go for it

I mean, if you are working on a distributed environment you should always ask to a synced source

Say again, for a synced policy file, you mean you want to use enforce as well as the other policy methods?

Oh ok. Sorry for the misunderstanding, yes that maybe is advanced casbin, me just learning that crazy stuff

Shouldn't be IMO... It should be agnostic, enforcement request is via literals defined in model p line. Your app defines the values to be passed to the enforcer, if there is a layer between your app and the enforcer, then it is a middleware, middleware receives objects from the app and passes enforcement request as plain text to casbin. That's my current understanding and I dont use middlewares I go directly to the enforcer like enforce(user-11, video-123, watch, 10-credits). But I know Java might be "easier" because everything should be mapped with something, easier not simpler.

AI is your friend too, casbin doc is not the best tou

UserId, resource, action, balance

Balance not necessarily if you save their balance on a g policy user vs balance

I recommend you to make a github search for java projects using keywords that matches with casbin and enforcement keywords

Oh sorry, I use casbin with python, where the enforcement is just as you do in the editor, you send the enforcement requests literals as they are defined in model.p

Can you send a casbin editor to see how matcher, policies and enforcement requests look like?. Your question is specific to Java Library or core Casbin functionality? If the later, we can help with the a editor instance

Provide more details. I've been struggling lately with Casbin but that situation has helped me to reach understanding. Gpt4 is no the best on Casbin but helps.