Flask Casbin Integration
Project description
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:
from flask import Flask
from flask_casbin import Casbin
app = Flask(__name__)
# config
app.config["CASBIN_MODEL_CONF"] = "./model.conf"
app.config["CASBIN_POLICY_CSV"] = "./policy.csv"
# create acl
acl = Casbin(app)
@app.route('/data/<id_:int>')
def get_data(id_):
# curent_user ist global authenticated user
acl.enforce("user:%s" % current_user.name, "data:%d" % 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 tests
Resources
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
Flask-Casbin-0.1.0.tar.gz
(6.4 kB
view hashes)
Built Distribution
Close
Hashes for Flask_Casbin-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ede584d3eae9a128d49fdf583ab89c48303fb8b83c875710a69a810ac01603f7 |
|
MD5 | 815c29dbdb99a06d2f94f86c75acb63e |
|
BLAKE2b-256 | daf9c00a2aa579119e1b6fc885d4072d9fe8f30cf39f31f3d9638fb045060a6e |