php-casbin / laravel-authz

An authorization library that supports access control models like ACL, RBAC, ABAC in Laravel.
Apache License 2.0
272 stars 46 forks source link

Get all v2 based on v0,v1,v3 values #46

Closed RafGiammario closed 1 year ago

RafGiammario commented 2 years ago

I'd like to retrive an array of v2 values based on v0,v1,v3 values, is there a function that I can't find in docs or have I to create a custom Enforcer?

This is my conf:

[request_definition]
r = sub, clt, obj, act

[policy_definition]
p = sub, clt, obj, act

[role_definition]
g = _, _

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = g(r.sub, p.sub) && ((r.clt == p.clt && r.obj == p.obj) || (r.clt == p.clt && r.obj == "*")) && r.act == p.act

Where sub is my user, clt is the table like (posts), obj is the id of obj in ctl and act is my action like index, edit, create, update, store, restore, destroy.

Can someone help me, pls?

hsluoyz commented 2 years ago

@M1sery

/cc @leeqvip

leeqvip commented 1 year ago

@RafGiammario You can use $e->getFilteredPolicy(1, "obj.id") to filter out the corresponding policies. see: https://casbin.org/docs/en/management-api#filtered-api

RafGiammario commented 1 year ago

Thanks