Skip to main content

SQLAlchemy Adapter for PyCasbin

Project description

SQLAlchemy Adapter for PyCasbin

Build Status Coverage Status Version PyPI - Wheel Pyversions Download License

SQLAlchemy Adapter is the SQLAlchemy adapter for PyCasbin. With this library, Casbin can load policy from Gorm supported database or save policy to it.

Based on Officially Supported Databases, The current supported databases are:

  • MySQL
  • PostgreSQL
  • Sqlite3
  • SQL Server

Installation

pip install casbin_sqlalchemy_adapter

Simple Example

import casbin_sqlalchemy_adapter
import casbin

adapter = casbin_sqlalchemy_adapter.Adapter('sqlite:///test.db')

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_sqlalchemy_adapter-0.0.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file casbin_sqlalchemy_adapter-0.0.1.tar.gz.

File metadata

  • Download URL: casbin_sqlalchemy_adapter-0.0.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.2

File hashes

Hashes for casbin_sqlalchemy_adapter-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e612c071fac4e3cc1db3526d029019662030ef5eb0bbc2a3bd913622e1f58e59
MD5 c0fc9d8a5eabff450f2fb3ef52fe5cf4
BLAKE2b-256 a0087126fafa5c97ee8278e24108d136b66b40522f99855aff142b02404cea7c

See more details on using hashes here.

File details

Details for the file casbin_sqlalchemy_adapter-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: casbin_sqlalchemy_adapter-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.2

File hashes

Hashes for casbin_sqlalchemy_adapter-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1725f9a8e5d92c1f3cf156283daa9b1ad7a27fc46a8425c730adaf3cda211f99
MD5 4e02b02bf110de3df2de5b22a6d24c97
BLAKE2b-256 6a3ba8511d7f8701e0d2c19ec749165abcf1574be49b8653574df3756255ed4e

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