Skip to main content

Flask-Casbin

Build Status

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

app = 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/<id_:int>')
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 tests

Resources

Metadata

Release files for flask-casbin 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flask-casbin 0.3.1
File Size Uploaded Provenance Actions
Flask-Casbin-0.3.1.tar.gz 7.2 kB Without provenance Details for Flask-Casbin-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flask-casbin 0.3.1
File Interpreter ABI Platform Actions
Flask_Casbin-0.3.1-py3-none-any.whl Python 3 none any Details for Flask_Casbin-0.3.1-py3-none-any.whl

Total release size: 15.4 kB

Release files / Flask-Casbin-0.3.1.tar.gz

Download URL Flask-Casbin-0.3.1.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d192633415d4dce71398ef6df0de7e7e290629bdfb1093b92561e76c0556f143
BLAKE2b-256 checksum
How to use checksums
bad3c617dd0940a860a6d795922ab92d4e95225826e0e854ad8152057fff89cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.6 Linux/5.11.16-arch1-1

Release files / Flask_Casbin-0.3.1-py3-none-any.whl

Download URL Flask_Casbin-0.3.1-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1dd0f5e098e9abc9d3c46e60bbcb0175758bdaaae6504a9a6e3cf9fa353f277d
BLAKE2b-256 checksum
How to use checksums
dc8f3e980c7f3ec1ed41f847e0c6ed97250aed230ce7424a2444bff02336b99b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.6 Linux/5.11.16-arch1-1

Security for flask-casbin 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page