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-0.1.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

casbin_pymongo_adapter-0.1.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: casbin_pymongo_adapter-0.1.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.9

File hashes

Hashes for casbin_pymongo_adapter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8c6c48c69f5413674d9d4b199b1cc41508409e778d54ede18079afdc5d5aea55
MD5 77a51741394d1b7c59b260113955bbca
BLAKE2b-256 f19ab02ec31d6e5ab94222b965bf224e5c98cd118ad53b8b9ff3ef2035ce25f9

See more details on using hashes here.

File details

Details for the file casbin_pymongo_adapter-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: casbin_pymongo_adapter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.7.9

File hashes

Hashes for casbin_pymongo_adapter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4a6db4ddada32c40a24c1726e666718927b0c3dab9604ab3d241be8da69d32d
MD5 a0251350da925db70a72199ec034add5
BLAKE2b-256 c3b47488bc77b0fd4e1295c143efe5293ebf30443e676360a97d37a41acadf4e

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