Pycasbin的Mongoengine_适配器。
casbin-mongoengine-adapter的Python项目详细描述
Pycasbin的MongoEngine适配器
MongoEngine适配器是PyCasbin的mongoengine适配器。使用此库,casbin可以从mongoengine支持的数据库加载策略或将策略保存到其中。
基于Officially Supported Databases,当前支持的数据库是:
- MongoDB
安装
pip install casbin_mongoengine_adapter
简单示例
importcasbin_mongoengine_adapterimportcasbinadapter=Adapter(dbname='casbin_test',host='mongodb://localhost:27017')e=casbin.Enforcer('path/to/model.conf',adapter,True)sub="alice"# the user that wants to access a resource.obj="data1"# the resource that is going to be accessed.act="read"# the operation that the user performs on the resource.ife.enforce(sub,obj,act):# permit alice to read data1casbin_mongoengine_adapterpasselse:# deny the request, show an errorpass
获得帮助
许可证
这个项目是根据Apache 2.0 license授权的。