Redis Adapter for PyCasbin
Redis Adapter is the Redis adapter for PyCasbin. With this library, Casbin can load policy from redis or save policy to it.
Installation
pip install casbin_redis_adapter
Simple Example
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 serviceport: redis service port
The following parameters are provided by default
db: redis database, default is0username: redis username, default isNonepassword: redis password, default isNonekey: casbin rule to store key, default iscasbin_rules
For more parameters, please follow redis-py
Getting Help
License
This project is licensed under the Apache 2.0 license.
Metadata
Release files for casbin-redis-adapter 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| casbin_redis_adapter-1.5.0.tar.gz | 9.2 kB | Without provenance | Details for casbin_redis_adapter-1.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| casbin_redis_adapter-1.5.0-py3-none-any.whl | Python 3 | none | any | Details for casbin_redis_adapter-1.5.0-py3-none-any.whl |
Total release size: 19.2 kB
Release files / casbin_redis_adapter-1.5.0.tar.gz
| Download URL | casbin_redis_adapter-1.5.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
17c7026b8b5460e41787591b4b09cb57193dd10d6cee2ed5883be40d551a7359
|
|
BLAKE2b-256 checksum How to use checksums |
ba6abf1b3355338e80f94f1c39028b87608be31eb892a4b838ca3b10073d8c08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Release files / casbin_redis_adapter-1.5.0-py3-none-any.whl
| Download URL | casbin_redis_adapter-1.5.0-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d769b7392073499ed42fa8135ec11711e82eefef952df8ee070b14817d7316b
|
|
BLAKE2b-256 checksum How to use checksums |
ec85d57c104fbe568695e1a97e486a67235f49e2f8e629445c9949b170761f79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Security for casbin-redis-adapter 1.5.0
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.