Redis Adapter for PyCasbin
====
[![GitHub Action](https://github.com/pycasbin/redis-adapter/workflows/build/badge.svg?branch=master)](https://github.com/pycasbin/redis-adapter/actions)
[![Coverage Status](https://coveralls.io/repos/github/pycasbin/redis-adapter/badge.svg)](https://coveralls.io/github/pycasbin/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/pycasbin/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": "BustDot",
"author_email": "Bust.dev@outlook.com",
"download_url": "https://files.pythonhosted.org/packages/d5/ac/36260f832166150e10462f10a187d83f594de75750bdb04cfe59b553d3b3/casbin_redis_adapter-1.2.0.tar.gz",
"platform": null,
"description": "Redis Adapter for PyCasbin\n====\n\n[![GitHub Action](https://github.com/pycasbin/redis-adapter/workflows/build/badge.svg?branch=master)](https://github.com/pycasbin/redis-adapter/actions)\n[![Coverage Status](https://coveralls.io/repos/github/pycasbin/redis-adapter/badge.svg)](https://coveralls.io/github/pycasbin/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\nlibrary, 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.2.0",
"project_urls": {
"Homepage": "https://github.com/pycasbin/redis-adapter"
},
"split_keywords": [
"casbin",
" redis",
" casbin-adapter",
" rbac",
" access control",
" abac",
" acl",
" permission"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "036c35da26ac81fcc0242081a5788213cf8b858e98677e54b730cf1d0e1debda",
"md5": "f784aa82cd1a3a2994154ea7f8d7ef64",
"sha256": "bd5b6f392818d3fb112cfe1bff3b3c2f6c2182d93929d580f7025f05fcddc322"
},
"downloads": -1,
"filename": "casbin_redis_adapter-1.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f784aa82cd1a3a2994154ea7f8d7ef64",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 9831,
"upload_time": "2024-03-29T11:20:23",
"upload_time_iso_8601": "2024-03-29T11:20:23.265522Z",
"url": "https://files.pythonhosted.org/packages/03/6c/35da26ac81fcc0242081a5788213cf8b858e98677e54b730cf1d0e1debda/casbin_redis_adapter-1.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d5ac36260f832166150e10462f10a187d83f594de75750bdb04cfe59b553d3b3",
"md5": "cbc901abded20d26653bb3922225f099",
"sha256": "e1c3605f6bf733134b8f5aba61d1e72c68272c89a981e7b88f6f3d803702e33c"
},
"downloads": -1,
"filename": "casbin_redis_adapter-1.2.0.tar.gz",
"has_sig": false,
"md5_digest": "cbc901abded20d26653bb3922225f099",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 9146,
"upload_time": "2024-03-29T11:20:24",
"upload_time_iso_8601": "2024-03-29T11:20:24.399472Z",
"url": "https://files.pythonhosted.org/packages/d5/ac/36260f832166150e10462f10a187d83f594de75750bdb04cfe59b553d3b3/casbin_redis_adapter-1.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-29 11:20:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pycasbin",
"github_project": "redis-adapter",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "casbin",
"specs": [
[
">=",
"0.8.1"
]
]
},
{
"name": "redis",
"specs": [
[
">=",
"4.5.0"
]
]
}
],
"lcname": "casbin-redis-adapter"
}