flask-casbin


Nameflask-casbin JSON
Version 0.3.1 PyPI version JSON
download
home_pagehttps://github.com/daymien/Flask-Casbin
SummaryFlask Casbin Integration
upload_time2021-06-10 21:02:20
maintainer
docs_urlNone
authorReimund Klain
requires_python>=3.6,<4.0
licenseApache-2.0
keywords flask casbin acl rbac abac auth authz authorization access control permission
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            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_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
---------

- [pypi](https://pypi.python.org/pypi/Flask-Casbin)
- [casbin](https://casbin.org/)
- [pycasbin](https://github.com/casbin/pycasbin)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/daymien/Flask-Casbin",
    "name": "flask-casbin",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6,<4.0",
    "maintainer_email": "",
    "keywords": "flask,casbin,acl,rbac,abac,auth,authz,authorization,access control,permission",
    "author": "Reimund Klain",
    "author_email": "reimund.klain@condevtec.de",
    "download_url": "https://files.pythonhosted.org/packages/ba/d3/c617dd0940a860a6d795922ab92d4e95225826e0e854ad8152057fff89cb/Flask-Casbin-0.3.1.tar.gz",
    "platform": "",
    "description": "Flask-Casbin\n============\n\n[![Build Status](https://travis-ci.org/daymien/Flask-Casbin.png?branch=master)](https://travis-ci.org/daymien/Flask-Casbin)\n\n\nFlask-Casbin is an extension that provide Casbin ACL functionality to your Flask project\n\nInstallation\n------------\n\nInstall Flask-Casbin with `pip`:\n\n    pip install Flask-Casbin\n\nInstall Flask-Casbin with `poetry`:\n\n    poetry add Flask-Casbin\n\nExample\n-------\n\nThis is an example Flask application:\n\n```python\nfrom flask import Flask, abort\nfrom flask_casbin import CasbinManager, IOAdapter, current_enforcer\n\napp = Flask(__name__)\n\n# config\napp.config[\"CASBIN_MODEL_CONF\"] = \"./model.conf\"\n\nacl = CasbinManager(app)\n\n@acl.policy_loader\ndef load_policy():\n    # some readable object for example based on current user\n    return IOAdapter(current_user.policy())\n\n@app.route('/data/<id_:int>')\ndef get_data(id_):\n    # curent_user ist global authenticated user\n    current_enforcer.enforce(f\"user:{current_user.name}\", f\"data:{id}\", \"read\") or abort(401)\n    \n    # Get data\n    data = db.get_data(id_)\n    return { data_id: data.id, data: data.payload }\n\n```\n\nTodo\n----\n\n* Decorators for ACL check\n* ~Policy adapters~\n* ~Dynamic Policy Adapter (Flask-SQLAlchemy)~\n* More tests\n\nResources\n---------\n\n- [pypi](https://pypi.python.org/pypi/Flask-Casbin)\n- [casbin](https://casbin.org/)\n- [pycasbin](https://github.com/casbin/pycasbin)\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Flask Casbin Integration",
    "version": "0.3.1",
    "split_keywords": [
        "flask",
        "casbin",
        "acl",
        "rbac",
        "abac",
        "auth",
        "authz",
        "authorization",
        "access control",
        "permission"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "acca338a1a1e6465b3364ccfa3d38080",
                "sha256": "1dd0f5e098e9abc9d3c46e60bbcb0175758bdaaae6504a9a6e3cf9fa353f277d"
            },
            "downloads": -1,
            "filename": "Flask_Casbin-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "acca338a1a1e6465b3364ccfa3d38080",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6,<4.0",
            "size": 8120,
            "upload_time": "2021-06-10T21:02:21",
            "upload_time_iso_8601": "2021-06-10T21:02:21.789828Z",
            "url": "https://files.pythonhosted.org/packages/dc/8f/3e980c7f3ec1ed41f847e0c6ed97250aed230ce7424a2444bff02336b99b/Flask_Casbin-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "36fccc351ec46029b65654bb909a8da8",
                "sha256": "d192633415d4dce71398ef6df0de7e7e290629bdfb1093b92561e76c0556f143"
            },
            "downloads": -1,
            "filename": "Flask-Casbin-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "36fccc351ec46029b65654bb909a8da8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6,<4.0",
            "size": 7237,
            "upload_time": "2021-06-10T21:02:20",
            "upload_time_iso_8601": "2021-06-10T21:02:20.361301Z",
            "url": "https://files.pythonhosted.org/packages/ba/d3/c617dd0940a860a6d795922ab92d4e95225826e0e854ad8152057fff89cb/Flask-Casbin-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-06-10 21:02:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "daymien",
    "error": "Could not fetch GitHub repository",
    "lcname": "flask-casbin"
}
        
Elapsed time: 0.29799s