casbin / jcasbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Java
https://casbin.org
Apache License 2.0
2.38k stars 461 forks source link

how to use gfunction #275

Closed headthick closed 2 years ago

headthick commented 2 years ago

i got some trouble ,my model is :

[request_definition]
r = sub, tenant, resource, obj, act

[policy_definition]
p = sub, tenant, resource, obj, act, eft

[role_definition]
g = _, _, _

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

[matchers]
m = g(r.sub, p.sub, p.tenant) && r.tenant == p.tenant && r.resource == p.resource && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act)

and my Policy is:

p, group1, tenant1, app1/Api, /api/v1/*, GET, allow
g, *, group1, tenant1

and my request is :

bob, tenant1, app1/Api, /api/v1/add, GET

js casbin config like this as follow (left side of site : https://casbin.org/zh-CN/editor ):

matchingForGFunction: 'keyMatch2',
matchingDomainForGFunction: 'keyMatch2'

it's Enforcement Result is : true

but in jcasbin, it is false

maven gav is :

<groupId>org.casbin</groupId>
<artifactId>jcasbin</artifactId>
<version>1.23.1</version>
casbin-bot commented 2 years ago

@tangyang9464 @seriouszyx @elfisworking @fangzhengjin

tangyang9464 commented 2 years ago

@headthick After #276 is merged, you can update jcasbin to the latest version, then use api addNamedMatchingFunc and addNamedDomainMatchingFunc. see rbac-with-pattern

github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 1.24.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: