SQLObject Adapter for PyCasbin

Clone this repo:
  1. 0ebf13f chore(release): 0.5.0 [skip ci] by semantic-release-bot · 7 months ago master v0.5.0
  2. 84e1903 feat: fix README badges (#2) by Theo · 7 months ago
  3. ac8674d chore(release): 0.4.0 [skip ci] by semantic-release-bot · 7 months ago v0.4.0
  4. 6d6653b feat: switch from casbin to pycasbin by Theo · 7 months ago
  5. f272e76 chore(release): 0.3.0 [skip ci] by semantic-release-bot · 1 year, 5 months ago v0.3.0

SQLObject Adapter for PyCasbin

GitHub Action Coverage Status Version PyPI - Wheel Pyversions Download License

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

The current supported databases are:

  • PostgreSQL
  • MySQL
  • SQLite
  • Microsoft SQL Server
  • Firebird
  • Sybase
  • MAX DB
  • pyfirebirdsql

Installation

pip install sqlobject_adapter

Simple Example

import sqlobject_adapter
import casbin

adapter = sqlobject_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.