项目作者: pycasbin

项目描述 :
PyMongo Adapter for PyCasbin
高级语言: Python
项目地址: git://github.com/pycasbin/pymongo-adapter.git
创建时间: 2020-06-13T09:56:37Z
项目社区:https://github.com/pycasbin/pymongo-adapter

开源协议:Apache License 2.0

下载


PyMongo Adapter for PyCasbin

Build Status
Coverage Status
Version
PyPI - Wheel
Pyversions
Download
License

PyMongo Adapter is the PyMongo adapter for PyCasbin. With this library, Casbin can load policy from MongoDB or save policy to it.

Installation

  1. pip install casbin_pymongo_adapter

Simple Example

  1. import casbin_pymongo_adapter
  2. import casbin
  3. adapter = casbin_pymongo_adapter.Adapter('mongodb://localhost:27017/', "dbname")
  4. e = casbin.Enforcer('path/to/model.conf', adapter, True)
  5. sub = "alice" # the user that wants to access a resource.
  6. obj = "data1" # the resource that is going to be accessed.
  7. act = "read" # the operation that the user performs on the resource.
  8. if e.enforce(sub, obj, act):
  9. # permit alice to read data1casbin_sqlalchemy_adapter
  10. pass
  11. else:
  12. # deny the request, show an error
  13. pass

Getting Help

License

This project is licensed under the Apache 2.0 license.