Multiple policies config?
See original GitHub issueHi, I’m new with Casbin and I’m trying to configure it with multiple policies like:
-
Feature policy (for each subscription plan, it will contain or not certain features): For example, for the subscription plan “professional” it will have the feature “insights” My policy config for this would be probably just:
p = sub, obj
-
Roles policy (basic ACL, like: admin, users, write): My policy config would be:
p2 = sub, obj, act
I read on https://casbin.org/docs/en/syntax-for-models#policy-definition that it’s actually possible to define multiple policies and you have some examples below, but I can’t find the way to make it work on node-casbin.
When adding the policy in the DB (I’m using casbin-sequelize-adapter
) it allows you to use “named” policies by using: e.addNamedPolicies
.
But when you want to enforce
and choose which namedPolicy you want to use, I can’t find how to do so.
This is the config I’m trying (I’m repeating all just in case based on the docs):
[request_definition]
r = sub, obj
r2 = sub, obj, act
[policy_definition]
p = sub, act # features
p2 = sub, obj, act # roles
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = r.sub == p.sub && r.obj == p.obj
m2 = r.sub == p.sub && r.obj == p.obj && r.act == p.act
Hope this is clear, thanks in advance.
Issue Analytics
- State:
- Created 2 years ago
- Comments:24 (18 by maintainers)
@yamilfrich
This function has been added and can be used later
ok!