Skip to main content

SQLAlchemy Adapter for PyCasbin

Project description

SQLAlchemy Adapter for PyCasbin

GitHub Actions Coverage Status Version PyPI - Wheel Pyversions Download License

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

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

  • PostgreSQL
  • MySQL
  • SQLite
  • Oracle
  • Microsoft SQL Server
  • Firebird
  • Sybase

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

Uploaded Source

Built Distribution

File details

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

File metadata

  • Download URL: casbin_sqlalchemy_adapter-0.4.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11

File hashes

Hashes for casbin_sqlalchemy_adapter-0.4.0.tar.gz
Algorithm Hash digest
SHA256 316030ced021bba705abeb5cefc77f6d19b81c1d5fbc01121b05360ae4b7f0a6
MD5 6cb79feec4f47edf6e9ada246317110b
BLAKE2b-256 f1ffc96bfdd78c5a9c75fe5b70d312b328075ec894846a5203d60bcb2c69c674

See more details on using hashes here.

File details

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

File metadata

  • Download URL: casbin_sqlalchemy_adapter-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11

File hashes

Hashes for casbin_sqlalchemy_adapter-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 087cc4a7b28f16d259a14a9e4221c4b760475a11443feb87892db8c752aec9c0
MD5 26e44db29edf9c01bf3b268dd5cdfef3
BLAKE2b-256 15fa639d9833e8b74de936c55fca2effc8988feff743d5c7cfe2fdd87f329af3

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