pycasbin的peewee适配器
casbin-peewee-adapter的Python项目详细描述
pycasbin的peewee适配器
peewee适配器是PyCasbin的Peewee适配器。使用此库,casbin可以从peewee支持的数据库加载策略或将策略保存到其中。
基于Officially Supported Databases,当前支持的数据库是:
- PostgreSQL
- mysql
- sqlite
安装
pip install casbin_peewee_adapter
简单示例
importcasbin_peewee_adapterimportcasbinimportpeeweeDATABAEE=peewee.SqliteDatabase('db.sqlite3')adapter=casbin_peewee_adapter.Adapter(database=DATABAEE)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_peewee_adapterpasselse:# deny the request, show an errorpass
获得帮助
许可证
这个项目是根据Apache 2.0 license授权的。