Skip to main content

Couchbase Adapter for PyCasbin

Project description

Couchbase Adapter for PyCasbin

Couchbase storage adapter for PyCasbin

Installation

pip install casbin_couchbase_adapter

# Create secondary index in Couchbase to support N1QL queries
CREATE INDEX idx_casbin ON content(meta().id, ptype) WHERE meta().id LIKE "casbin_rule%"

Simple Example

import casbin_couchbase_adapter
import casbin

adapter = casbin_couchbase_adapter.Adapter('couchbase://localhost:8091', 'bucket', 'user', 'password')

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 data1
    pass
else:
    # deny the request, show an error
    pass

Development

  1. Fork
  2. Install Dev ENV
# Install Flask-Casbin with Dev packages
pip install -r dev_requirements.txt
pip install -r requirements.txt
pip install -e .
# Install Pre-commits
pre-commit install
# Create feature branch
git checkout -b feature-more-cool-stuff
# Code stuff

Then push your changes and create a PR

Manually Bump Version

bumpversion major  # major release
or
bumpversion minor  # minor release
or
bumpversion patch  # hotfix release

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

casbin_couchbase_adapter-0.2.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file casbin_couchbase_adapter-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for casbin_couchbase_adapter-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2890b87210f3dd916d3505797d7a87b86360039b17300f2a2249e436660dada2
MD5 a78a34f9d7bde699f31652d35d33a465
BLAKE2b-256 bffa61272a4a4cddbe615496f443c0cbd4bf783232b150cc09dfc855df4da23b

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