Redis Adapter for PyCasbin
====
[![GitHub Action](https://github.com/officialpycasbin/redis-adapter/workflows/build/badge.svg?branch=master)](https://github.com/officialpycasbin/redis-adapter/actions)
[![Coverage Status](https://coveralls.io/repos/github/officialpycasbin/redis-adapter/badge.svg)](https://coveralls.io/github/officialpycasbin/redis-adapter)
[![Version](https://img.shields.io/pypi/v/casbin_redis_adapter.svg)](https://pypi.org/project/casbin_redis_adapter/)
[![PyPI - Wheel](https://img.shields.io/pypi/wheel/casbin_redis_adapter.svg)](https://pypi.org/project/casbin_redis_adapter/)
[![Pyversions](https://img.shields.io/pypi/pyversions/casbin_redis_adapter.svg)](https://pypi.org/project/casbin_redis_adapter/)
[![Download](https://img.shields.io/pypi/dm/casbin_redis_adapter.svg)](https://pypi.org/project/casbin_redis_adapter/)
[![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord&label=discord&color=5865F2)](https://discord.gg/S5UjpzGZjN)
Redis Adapter is the [Redis](https://redis.io/) adapter for [PyCasbin](https://github.com/casbin/pycasbin). With this library, Casbin can load policy from redis or save policy to it.
## Installation
```
pip install casbin_redis_adapter
```
## Simple Example
```python
import casbin_redis_adapter
import casbin
adapter = casbin_redis_adapter.Adapter('localhost', 6379)
e = casbin.Enforcer('path/to/model.conf', adapter, True)
sub = "alice" # the user that wants to access a resource.
obj = "data1" # the resource that is going to be accessed.
act = "read" # the operation that the user performs on the resource.
if e.enforce(sub, obj, act):
# permit alice to read data1casbin_sqlalchemy_adapter
pass
else:
# deny the request, show an error
pass
```
## Configuration
`Adapter()` enable decode_responses by default and supports any Redis parameter configuration.
To use casbin_redis_adapter, you must provide the following parameter configuration
- `host`: address of the redis service
- `port`: redis service port
The following parameters are provided by default
- `db`: redis database, default is `0`
- `username`: redis username, default is `None`
- `password`: redis password, default is `None`
- `key`: casbin rule to store key, default is `casbin_rules`
For more parameters, please follow [redis-py](https://redis.readthedocs.io/en/stable/connections.html#redis.Redis)
### Getting Help
- [PyCasbin](https://github.com/casbin/pycasbin)
### License
This project is licensed under the [Apache 2.0 license](LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/officialpycasbin/redis-adapter",
"name": "casbin-redis-adapter",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "casbin, Redis, casbin-adapter, rbac, access control, abac, acl, permission",
"author": "Casbin",
"author_email": "admin@casbin.org",
"download_url": "https://files.pythonhosted.org/packages/c5/21/515bcfdecdec59ab2634f989ac71f63f6d18a3805efc2861d96deb7e13f1/casbin_redis_adapter-1.3.0.tar.gz",
"platform": null,
"description": "Redis Adapter for PyCasbin\n====\n\n[![GitHub Action](https://github.com/officialpycasbin/redis-adapter/workflows/build/badge.svg?branch=master)](https://github.com/officialpycasbin/redis-adapter/actions)\n[![Coverage Status](https://coveralls.io/repos/github/officialpycasbin/redis-adapter/badge.svg)](https://coveralls.io/github/officialpycasbin/redis-adapter)\n[![Version](https://img.shields.io/pypi/v/casbin_redis_adapter.svg)](https://pypi.org/project/casbin_redis_adapter/)\n[![PyPI - Wheel](https://img.shields.io/pypi/wheel/casbin_redis_adapter.svg)](https://pypi.org/project/casbin_redis_adapter/)\n[![Pyversions](https://img.shields.io/pypi/pyversions/casbin_redis_adapter.svg)](https://pypi.org/project/casbin_redis_adapter/)\n[![Download](https://img.shields.io/pypi/dm/casbin_redis_adapter.svg)](https://pypi.org/project/casbin_redis_adapter/)\n[![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord&label=discord&color=5865F2)](https://discord.gg/S5UjpzGZjN)\n\nRedis Adapter is the [Redis](https://redis.io/) adapter for [PyCasbin](https://github.com/casbin/pycasbin). With this library, Casbin can load policy from redis or save policy to it.\n\n## Installation\n\n```\npip install casbin_redis_adapter\n```\n\n## Simple Example\n\n```python\nimport casbin_redis_adapter\nimport casbin\n\nadapter = casbin_redis_adapter.Adapter('localhost', 6379)\n\ne = casbin.Enforcer('path/to/model.conf', adapter, True)\n\nsub = \"alice\" # the user that wants to access a resource.\nobj = \"data1\" # the resource that is going to be accessed.\nact = \"read\" # the operation that the user performs on the resource.\n\nif e.enforce(sub, obj, act):\n # permit alice to read data1casbin_sqlalchemy_adapter\n pass\nelse:\n # deny the request, show an error\n pass\n```\n\n## Configuration\n\n`Adapter()` enable decode_responses by default and supports any Redis parameter configuration.\n\nTo use casbin_redis_adapter, you must provide the following parameter configuration\n\n- `host`: address of the redis service\n- `port`: redis service port\n\nThe following parameters are provided by default\n\n- `db`: redis database, default is `0`\n- `username`: redis username, default is `None`\n- `password`: redis password, default is `None`\n- `key`: casbin rule to store key, default is `casbin_rules`\n\nFor more parameters, please follow [redis-py](https://redis.readthedocs.io/en/stable/connections.html#redis.Redis)\n\n### Getting Help\n\n- [PyCasbin](https://github.com/casbin/pycasbin)\n\n### License\n\nThis project is licensed under the [Apache 2.0 license](LICENSE).\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "Redis Adapter for PyCasbin",
"version": "1.3.0",
"project_urls": {
"Homepage": "https://github.com/officialpycasbin/redis-adapter"
},
"split_keywords": [
"casbin",
" redis",
" casbin-adapter",
" rbac",
" access control",
" abac",
" acl",
" permission"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "82a9e7286e61cd710bd0f23b8381d54005f4a92117e350209476bd2fa2bd9faa",
"md5": "bc21d4fcfc2aa3632e3a94cc2b66e327",
"sha256": "9d9ca87359bcb823205b5305baa983fbe0e662319e74bdb64fa6f3813c5662f1"
},
"downloads": -1,
"filename": "casbin_redis_adapter-1.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bc21d4fcfc2aa3632e3a94cc2b66e327",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 9833,
"upload_time": "2024-11-12T02:06:46",
"upload_time_iso_8601": "2024-11-12T02:06:46.446465Z",
"url": "https://files.pythonhosted.org/packages/82/a9/e7286e61cd710bd0f23b8381d54005f4a92117e350209476bd2fa2bd9faa/casbin_redis_adapter-1.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c521515bcfdecdec59ab2634f989ac71f63f6d18a3805efc2861d96deb7e13f1",
"md5": "3adc9305f8648bcd9806412f42394a40",
"sha256": "3d53413951b9e37630c62b18960f30aef26fa3f6b7d113ee944b34d545b3d2dc"
},
"downloads": -1,
"filename": "casbin_redis_adapter-1.3.0.tar.gz",
"has_sig": false,
"md5_digest": "3adc9305f8648bcd9806412f42394a40",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 9143,
"upload_time": "2024-11-12T02:06:48",
"upload_time_iso_8601": "2024-11-12T02:06:48.070895Z",
"url": "https://files.pythonhosted.org/packages/c5/21/515bcfdecdec59ab2634f989ac71f63f6d18a3805efc2861d96deb7e13f1/casbin_redis_adapter-1.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-12 02:06:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "officialpycasbin",
"github_project": "redis-adapter",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "casbin-redis-adapter"
}