amisadmin / fastapi-user-auth

FastAPI-User-Auth is a simple and powerful FastAPI user RBAC authentication and authorization library. Based on FastAPI-Amis-Admin and provides a freely extensible visual management interface.
338 stars 43 forks source link

使用add_grouping_policy添加子角色继承, 但是require在判定角色时不能识别继承的子角色 #42

Open one-pyy opened 5 months ago

one-pyy commented 5 months ago
await auth.create_role_user("admin")
await auth.create_role_user("root")
await auth.enforcer.add_grouping_policy("r:root", "r:admin")
# 在dependencies中使用root验证auth.requires("admin")失败

在auth.has_role_for_user函数中, 能否使用self.enforcer.get_implicit_roles_for_user再自己判定呢?

(也看到casbin没有提供has_implicit_roles_for_user了, 可能这其中有效率之类的考虑。如果是我的使用方式有问题, 请告诉我, 非常感谢!)