Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

it works on Casbin Editor, but failed locally #959

Closed
neWs1587 opened this issue Feb 21, 2022 · 1 comment
Closed

it works on Casbin Editor, but failed locally #959

neWs1587 opened this issue Feb 21, 2022 · 1 comment
Assignees
Labels

Comments

@neWs1587
Copy link

Want to prioritize this issue? Try:

issuehunt-to-marktext


when I set matchingForGFunction: 'keyMatch' on casbin online editor, it works.
but when i set it as the following locally

	enforcer.AddNamedDomainMatchingFunc("g", "", util.KeyMatch)
	enforcer.AddNamedMatchingFunc("g", "", util.KeyMatch)

i always get 'false'. How can i deal with it?

model:

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

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

[role_definition]
g = _, _, _

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

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

policy:

p, admin, *, data1, read
p, admin, *, data1, write

g, alice, admin, domain1

request(s):

alice, domain1, data1, write ---> false (expected: true)

code

func main() {
	enforcer, _ := casbin.NewEnforcer("./model.conf", "./policy.csv")

	enforcer.AddNamedDomainMatchingFunc("g", "", util.KeyMatch)
	enforcer.AddNamedMatchingFunc("g", "", util.KeyMatch)

	ok, _ := enforcer.Enforce("alice", "domian1", "data1", "write")
	fmt.Println("alice write data1", ok)
}
@casbin-bot
Copy link
Member

@tangyang9464 @closetool @sagilio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants