Skip to main content

Flask Casbin Integration

Project description


Build Status

Flask-Casbin is an extension that provide Casbin ACL functionality to your Flask project


Install Flask-Casbin with pip:

pip install Flask-Casbin

Install Flask-Casbin with poetry:

poetry add Flask-Casbin


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)

def get_data(id_):
    # curent_user ist global authenticated user
    acl.enforce("user:%s" %, "data:%d" % id_, "read") or abort(401)

    # Get data
    data = db.get_data(id_)
    return { data_id:, data: data.payload }


  • Decorators for ACL check
  • Policy adapters
  • Dynamic Policy Adapter (Flask-SQLAlchemy)
  • More tests


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flask-casbin, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size Flask_Casbin-0.2.1-py3-none-any.whl (8.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size Flask-Casbin-0.2.1.tar.gz (7.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page