跳转到主要内容

PyCasbin的PyMongo适配器

项目描述

PyCasbin的PyMongo适配器

Build Status Coverage Status Version PyPI - Wheel Pyversions Download License

PyMongo适配器是PyMongo的适配器,用于PyCasbin。使用这个库,Casbin可以从MongoDB加载策略或将其保存到MongoDB。

安装

pip install casbin_pymongo_adapter

简单示例

import casbin_pymongo_adapter
import casbin

adapter = casbin_pymongo_adapter.Adapter('mongodb://localhost:27017/', "dbname")

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.

if e.enforce(sub, obj, act):
    # permit alice to read data1casbin_sqlalchemy_adapter
    pass
else:
    # deny the request, show an error
    pass

获取帮助

许可证

本项目采用Apache 2.0许可证

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码发行版

casbin_pymongo_adapter-1.1.0.tar.gz (9.2 kB 查看哈希值)

上传时间: 源代码

构建发行版

casbin_pymongo_adapter-1.1.0-py2.py3-none-any.whl (9.2 kB 查看哈希值)

上传时间: Python 2 Python 3

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页