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

Uploaded Source

Built Distribution

casbin_sqlalchemy_adapter-0.5.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for casbin_sqlalchemy_adapter-0.5.0.tar.gz
Algorithm Hash digest
SHA256 41e0becc335f058def667993d11a339d50e931890e8f4f02177e6e3839082399
MD5 3d10efa5f1ff7ede5593e394256bd799
BLAKE2b-256 252e6fa8b2870008c09fbee959ece078e1195ad51821e800de66d3bc2868d5dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for casbin_sqlalchemy_adapter-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1241f8320d33f6bab634bf9fa650dc6cb2ab0b0b587fee61bf30c54228a50488
MD5 cf30a41346df412edf14d9a096fbbd61
BLAKE2b-256 1390e014c6153fe2b01addded59041b9e113fc8342c4d2be58edde1a1516e117

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