question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple policies config?

See original GitHub issue

Hi, 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:open
  • Created 2 years ago
  • Comments:24 (18 by maintainers)

github_iconTop GitHub Comments

3reactions
Gabriel-403commented, Aug 21, 2021

@yamilfrich

This function has been added and can be used later

3reactions
Gabriel-403commented, Aug 13, 2021

@Zxilly @Gabriel-403 plz implement it

ok!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best Practice for Multiple Configuration Policies
I'm looking for some guidance on the best practice setup when dealing with multiple restriction policies for multiple user groups.
Read more >
If I configure multiple Duo policies, in which order are they ...
When a user belongs to multiple groups with multiple group policies applied to each application, the group policy order is relevant.
Read more >
AWS managed policies for AWS Config
This managed policy contains read-only and write-only permissions for AWS Config resources and read-only permissions for resources in other services that AWS ...
Read more >
Whats the best practise when creating multiple policies : r/Intune
When creating policies in device configuration to lock devices down, is it best practise to create multiple policies? As in just setup a ......
Read more >
Want to configure multiple policies and objects through cli ...
Hi all, Hope you all are doing Good. Guys, I have a query can we configure multiple Nat policies, security policies, address objects, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found