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, abort
from flask_casbin import CasbinManager, IOAdapter, current_enforcer

app = Flask(__name__)

# config
app.config["CASBIN_MODEL_CONF"] = "./model.conf"

acl = CasbinManager(app)

def load_policy():
    # some readable object for example based on current user
    return IOAdapter(current_user.policy())

def get_data(id_):
    # curent_user ist global authenticated user
    current_enforcer.enforce(f"user:{}", f"data:{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.

Source Distribution

Flask-Casbin-0.3.1.tar.gz (7.2 kB view hashes)

Uploaded source

Built Distribution

Flask_Casbin-0.3.1-py3-none-any.whl (8.1 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page