https://github.com/pycasbin/pymongo-adapter
PyMongo Adapter for PyCasbin
https://github.com/pycasbin/pymongo-adapter
abac access-control acl casbin permissions rbac security
Last synced: about 2 months ago
JSON representation
PyMongo Adapter for PyCasbin
- Host: GitHub
- URL: https://github.com/pycasbin/pymongo-adapter
- Owner: pycasbin
- License: apache-2.0
- Created: 2020-06-13T09:56:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-26T05:23:52.000Z (12 months ago)
- Last Synced: 2024-12-13T21:43:41.925Z (10 months ago)
- Topics: abac, access-control, acl, casbin, permissions, rbac, security
- Language: Python
- Size: 29.3 KB
- Stars: 10
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
PyMongo Adapter for PyCasbin
====[](https://www.travis-ci.org/pycasbin/pymongo-adapter)
[](https://coveralls.io/github/pycasbin/pymongo-adapter)
[](https://pypi.org/project/casbin_pymongo_adapter/)
[](https://pypi.org/project/casbin_pymongo_adapter/)
[](https://pypi.org/project/casbin_pymongo_adapter/)
[](https://pypi.org/project/casbin_pymongo_adapter/)
[](https://pypi.org/project/casbin_pymongo_adapter/)PyMongo Adapter is the [PyMongo](https://pypi.org/project/pymongo/) adapter for [PyCasbin](https://github.com/casbin/pycasbin). With this library, Casbin can load policy from MongoDB or save policy to it.
## Installation
```
pip install casbin_pymongo_adapter
```## Simple Example
```python
import casbin_pymongo_adapter
import casbinadapter = 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
```### Getting Help
- [PyCasbin](https://github.com/casbin/pycasbin)
### License
This project is licensed under the [Apache 2.0 license](LICENSE).