Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reimundklain/flask-casbin
Provide context local casbin dynamic enforcer to your flask project
https://github.com/reimundklain/flask-casbin
abac acl authorization casbin flask permssions rbac
Last synced: 2 months ago
JSON representation
Provide context local casbin dynamic enforcer to your flask project
- Host: GitHub
- URL: https://github.com/reimundklain/flask-casbin
- Owner: reimundklain
- License: apache-2.0
- Created: 2019-10-10T20:27:54.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-10T21:07:08.000Z (over 3 years ago)
- Last Synced: 2024-10-10T08:23:26.133Z (2 months ago)
- Topics: abac, acl, authorization, casbin, flask, permssions, rbac
- Language: Python
- Homepage:
- Size: 35.2 KB
- Stars: 9
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Official Version Available:
===========================https://github.com/pycasbin/flask-authz/
Flask-Casbin
============[![Build Status](https://travis-ci.org/daymien/Flask-Casbin.png?branch=master)](https://travis-ci.org/daymien/Flask-Casbin)
Flask-Casbin is an extension that provide Casbin ACL functionality to your Flask project
Installation
------------Install Flask-Casbin with `pip`:
pip install Flask-Casbin
Install Flask-Casbin with `poetry`:
poetry add Flask-Casbin
Example
-------This is an example Flask application:
```python
from flask import Flask, abort
from flask_casbin import CasbinManager, IOAdapter, current_enforcerapp = Flask(__name__)
# config
app.config["CASBIN_MODEL_CONF"] = "./model.conf"acl = CasbinManager(app)
@acl.policy_loader
def load_policy():
# some readable object for example based on current user
return IOAdapter(current_user.policy())@app.route('/data/')
def get_data(id_):
# curent_user ist global authenticated user
current_enforcer.enforce(f"user:{current_user.name}", f"data:{id}", "read") or abort(401)
# Get data
data = db.get_data(id_)
return { data_id: data.id, data: data.payload }```
Todo
----* Decorators for ACL check
* ~Policy adapters~
* ~Dynamic Policy Adapter (Flask-SQLAlchemy)~
* More testsResources
---------- [pypi](https://pypi.python.org/pypi/Flask-Casbin)
- [casbin](https://casbin.org/)
- [pycasbin](https://github.com/casbin/pycasbin)