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

请教一个问题,表结构 没有 用到 casbin默认的那个表,它是如何进行判断的。 #6

Closed
hequan2017 opened this issue Jan 9, 2019 · 2 comments

Comments

@hequan2017
Copy link

hequan2017 commented Jan 9, 2019

刚go 初学,看了半天,没找到。

@hsluoyz
Copy link

hsluoyz commented Jan 9, 2019

@hequan2017 , 代码里初始化Casbin Enforcer的时候,确实没有指定Adapter,也就不会加载任何策略、数据库表。他是把逻辑写在model里了:https://github.com/LyricTian/gin-admin/blob/master/config/model.conf

[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) == true \
    && keyMatch2(r.obj, p.obj) == true \
    && regexMatch(r.act, p.act) == true \
    || r.sub == "root" \
    || keyMatch2(r.obj, "/api/v1/login") == true \
    || keyMatch2(r.obj, "/api/v1/logout") == true \
    || keyMatch2(r.obj, "/api/v1/current/menus") == true \
    || keyMatch2(r.obj, "/api/v1/current/user") == true

所以实现了和Adapter类似的效果,不过按道理说,/api/v1/login 这些具体RESTful路径,应该是放到policy(csv文件、数据库)里的

@hequan2017
Copy link
Author

了解了。感谢作者。 期待后续功能。

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

2 participants