PyCasbin的Redis适配器
项目描述
PyCasbin的Redis适配器
Redis适配器是redis的PyCasbin适配器。使用此库,Casbin可以从redis中加载策略或将策略保存到redis中。
安装
pip install casbin_redis_adapter
简单示例
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
配置
Adapter()
默认启用 decode_responses 并支持任何Redis参数配置。
要使用 casbin_redis_adapter,您必须提供以下参数配置
host
:redis服务的地址port
:redis服务端口
以下参数默认提供
db
:redis数据库,默认为0
username
:redis用户名,默认为None
password
:redis密码,默认为None
key
:存储casbin规则的key,默认为casbin_rules
有关更多参数,请参考redis-py
获取帮助
许可证
此项目采用Apache 2.0许可证。
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源代码分发
casbin_redis_adapter-1.2.0.tar.gz (9.1 kB 查看哈希值)
构建分发
关闭
casbin_redis_adapter-1.2.0.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e1c3605f6bf733134b8f5aba61d1e72c68272c89a981e7b88f6f3d803702e33c |
|
MD5 | cbc901abded20d26653bb3922225f099 |
|
BLAKE2b-256 | d5ac36260f832166150e10462f10a187d83f594de75750bdb04cfe59b553d3b3 |
关闭
casbin_redis_adapter-1.2.0-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | bd5b6f392818d3fb112cfe1bff3b3c2f6c2182d93929d580f7025f05fcddc322 |
|
MD5 | f784aa82cd1a3a2994154ea7f8d7ef64 |
|
BLAKE2b-256 | 036c35da26ac81fcc0242081a5788213cf8b858e98677e54b730cf1d0e1debda |