Closed ghost closed 3 years ago
Here is my go.mod:
go 1.16
require ( github.com/EntropyPool/entropy-logger v0.0.0-20210320022718-3091537e035f github.com/NpoolRD/http-daemon v0.0.0-20210505073728-a1d91b8af9df github.com/casbin/casbin v1.9.1 github.com/casbin/casbin/v2 v2.36.1 github.com/casbin/xorm-adapter/v2 v2.3.2 github.com/go-sql-driver/mysql v1.6.0 github.com/urfave/cli/v2 v2.3.0 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 )
here is my code:
a, err := xormadapter.NewAdapter("mysql", "root:123456@tcp(172.17.0.2:3306)/casbin", true)
if err != nil {
log.Fatalf("error: adapter: %s", err)
}
m, err := model.NewModelFromString(`
[request_definition]
r = sub, obj, act
[policy_definition]
p = sub, obj, act
[role_definition]
g = _, _
[policy_effect]
e = some(where (p.eft == allow))
[matchers]
m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act
`)
if err != nil {
log.Fatalf("error: model: %s", err)
}
e, err := casbin.NewEnforcer(m, a)
if err != nil {
log.Fatalf("error: enforcer: %s", err)
}
updated, err := e.UpdateGroupingPolicy([]string{"zpl", "admin"}, []string{"zpl", "person"})
if err != nil {
fmt.Println("update err is:", err)
return
}
if updated {
fmt.Println("updated")
} else {
fmt.Println("not updated")
}
@closetool @tangyang9464
:tada: This issue has been resolved in version 2.4.0 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket:
I am using xorm-adapter and mysql together to update policy and group policy, but here the error occurred:
And if I use a csv file above is not happened.