node-casbin icon indicating copy to clipboard operation
node-casbin copied to clipboard

Support WildCard Match in getFilteredPolicy

Open kerituni12 opened this issue 2 years ago • 7 comments

Example : I have subject admin:create:any , admin:create:own, i need wildcard to get matched subject and then check value is any or own to handle my business logic

getFilteredPolicy(0, 'admin:create:*', 'user', 'create')

I think the getFilteredPolicy() support something like

 if (fieldValue !== '' && rule[fieldIndex + i] !== fieldValue && !picomatch.isMatch(rule[fieldIndex + i], fieldValue)) {
          matched = false;
          break;
 }

kerituni12 avatar Apr 14 '22 08:04 kerituni12

@Gabriel-403 @Zxilly @kingiw @nodece

casbin-bot avatar Apr 14 '22 09:04 casbin-bot

@Shivansh-yadav13

hsluoyz avatar Apr 14 '22 11:04 hsluoyz

working on it.

Shivansh-yadav13 avatar Apr 14 '22 15:04 Shivansh-yadav13

@hsluoyz maybe we can create a method so that wildcard support can be added for all such types of methods. should we focus on adding something like that?

Shivansh-yadav13 avatar Apr 14 '22 16:04 Shivansh-yadav13

@kerituni12 please review #361

Shivansh-yadav13 avatar Apr 16 '22 05:04 Shivansh-yadav13

I am using casdoor with node-casbin, and after I created a permission with role (no user added), I got following policy in casbin_rule table

image

The g type policy uses wildcard for users under normal_group. But I cannot get it supported by node-casbin...

tangramor avatar Apr 21 '23 09:04 tangramor

@tangramor what you said is a different problem. Please create a new issue

hsluoyz avatar Apr 21 '23 13:04 hsluoyz