Skip to main content

PyMongo Adapter for PyCasbin

Project description

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

pip install casbin_pymongo_adapter

Simple Example

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

Getting Help

License

This project is licensed under the Apache 2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

casbin_pymongo_adapter-1.1.1.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

casbin_pymongo_adapter-1.1.1-py2.py3-none-any.whl (9.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file casbin_pymongo_adapter-1.1.1.tar.gz.

File metadata

File hashes

Hashes for casbin_pymongo_adapter-1.1.1.tar.gz
Algorithm Hash digest
SHA256 c5c442e4ea5584bd50c0986c447f177281faa6432d1aeda4f71ca0f20af24551
MD5 1749c70cd962379ac648cb228065ad6a
BLAKE2b-256 dae55c506f17689ac6d4214c76357c76c46103fae97835830b2b98f25efd4f39

See more details on using hashes here.

File details

Details for the file casbin_pymongo_adapter-1.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for casbin_pymongo_adapter-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4d8e71b0747b4e9efb781d5ede07d9410898e1f551d6807a47ad076f51bf66c8
MD5 92e229cb61592b572ebe714ce950b409
BLAKE2b-256 3df5c4b58962b3617090f2f6ae7adebd595773897288a2e7d5d9779ed91329f9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page