Merge pull request #1 from princekrroshan01/master

first commit
tree: 89bcd9f0f57f673b8753ca931569bc7bbf483311
  1. casbin_sqlobject_adapter/
  2. tests/
  3. .coveragerc
  4. .gitignore
  5. .travis.yml
  6. LICENSE
  7. README.md
  8. requirements.txt
  9. setup.py
README.md

SQLObject Adapter for PyCasbin

Build Status 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 casbin_sqlobject_adapter

Simple Example

import casbin_sqlobject_adapter
import casbin

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