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

roles bug #9

Open
dfang opened this issue May 30, 2019 · 0 comments
Open

roles bug #9

dfang opened this issue May 30, 2019 · 0 comments

Comments

@dfang
Copy link

dfang commented May 30, 2019

发现文档中的3, 并不准确

If even one (1) Allow mapping exists, then only roles on that list will be allowed through.

permission := roles.Allow(roles.Read, "admin")
// permission := roles.Allow(roles.Read, "admin").Deny(roles.Read, "operator")
fmt.Println(permission.HasPermission(roles.Read, "operator"))

// only admin can see products management menu and crud on products
Admin.AddMenu(&admin.Menu{Name: "Product Management", Priority: 1, Permission: permission})
product := Admin.AddResource(&products.Product{}, &admin.Config{Menu: []string{"Product Management"}, Permission: permission})

fmt 输出的是false
但是用operator角色的账号登录能看到Product Management这个菜单
所有角色都通过roles.Register 注册过

建议permission判断这一块使用casbin来判断

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

No branches or pull requests

1 participant