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

GFunction doesn't work well on website editor #34

Closed
wim-web opened this issue Apr 22, 2021 · 11 comments
Closed

GFunction doesn't work well on website editor #34

wim-web opened this issue Apr 22, 2021 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@wim-web
Copy link

wim-web commented Apr 22, 2021

I used the same model, policy, and request, but the results were different between the website editor and local code.

on website

スクリーンショット 2021-04-22 22 52 01

on local code

model.conf

[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[role_definition]
g = _, _
g2 = _, _

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

[matchers]
m = g(r.sub, p.sub)

policy.csv

p, admin, data1, read

g2, alice, admin

main.go

package main

import (
	"fmt"

	"github.com/casbin/casbin/v2"
)

func main() {
	e, _ := casbin.NewEnforcer("./model.conf", "./policy.csv")
	res, _ := e.Enforce("alice", "data1", "read")
	fmt.Print(res) // display false
}

go.mod

module casbin

go 1.15

require github.com/casbin/casbin/v2 v2.28.2 // indirect

@hsluoyz
Copy link
Member

hsluoyz commented Apr 22, 2021

@wim-web I think Casbin-editor may have bug.

@Zxilly plz fix it.

@hsluoyz hsluoyz self-assigned this Apr 22, 2021
@Zxilly
Copy link
Contributor

Zxilly commented Apr 22, 2021

working on this

@Zxilly
Copy link
Contributor

Zxilly commented Apr 23, 2021

@hsluoyz I believe this is different default behavior between node-casbin and golang-casbin.
Plz move this to node-casbin.

@hsluoyz hsluoyz transferred this issue from casbin/casbin-editor Apr 23, 2021
@nodece nodece transferred this issue from casbin/node-casbin Apr 29, 2021
@nodece
Copy link
Member

nodece commented Apr 29, 2021

@hsluoyz this is Golang-casbin issue. the alice belong to admin role, so aclice, data1, read is true.

@Zxilly
Copy link
Contributor

Zxilly commented Apr 29, 2021

@nodece He didn't use g2(r.sub, p.sub) to build role link, so g2, alice, admin should be ignored.

@hsluoyz
Copy link
Member

hsluoyz commented Apr 29, 2021

@nodece He didn't use g2(r.sub, p.sub) to build role link, so g2, alice, admin should be ignored.

Agreed with @Zxilly

So this is still a Node-Casbin issue..

@nodece
Copy link
Member

nodece commented Apr 29, 2021

@hsluoyz @Zxilly g and g2 uses same role manager, so g == g2 and returns true. I tried to use jcasbin and node-casbin to check this model and policy, which returns true. If golang-casbin is right, we should update all code.

@hsluoyz
Copy link
Member

hsluoyz commented Apr 29, 2021

@nodece that's right.

@Zxilly plz update Node-Casbin

@hsluoyz hsluoyz transferred this issue from casbin/casbin Apr 29, 2021
@Zxilly
Copy link
Contributor

Zxilly commented Apr 29, 2021

@nodece We have updated rm to rmMap, now every group has its own role manager.
This is meant to use different match function on different role.

@nodece
Copy link
Member

nodece commented Apr 29, 2021

@hsluoyz I checkout go-casbin to check this issue, we need to update casbin of other program language.

@Zxilly thanks for your contribution :)

@hsluoyz hsluoyz transferred this issue from casbin/node-casbin May 7, 2021
@hsluoyz hsluoyz added the bug Something isn't working label May 7, 2021
@hsluoyz
Copy link
Member

hsluoyz commented May 7, 2021

@nodece plz update the editor version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants