https://github.com/jcasbin/redis-adapter
Redis adapter for Casbin
https://github.com/jcasbin/redis-adapter
access-control adapter auth authorization authz casbin java jcasbin redis
Last synced: 6 months ago
JSON representation
Redis adapter for Casbin
- Host: GitHub
- URL: https://github.com/jcasbin/redis-adapter
- Owner: jcasbin
- License: apache-2.0
- Created: 2021-04-01T08:05:00.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-02T08:48:03.000Z (7 months ago)
- Last Synced: 2024-11-16T01:32:59.265Z (6 months ago)
- Topics: access-control, adapter, auth, authorization, authz, casbin, java, jcasbin, redis
- Language: Java
- Homepage: https://github.com/casbin/jcasbin
- Size: 30.3 KB
- Stars: 5
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Redis Adapter
[](https://github.com/jcasbin/redis-adapter/actions)
[](https://codebeat.co/projects/github-com-jcasbin-redis-adapter-master)
[](https://codecov.io/gh/jcasbin/redis-adapter)
[](https://www.javadoc.io/doc/org.casbin/redis-adapter)
[](https://mvnrepository.com/artifact/org.casbin/redis-adapter/latest)
[](https://discord.gg/S5UjpzGZjN)Redis Adapter is the [Redis](https://redis.io/) adapter for [jCasbin](https://github.com/casbin/jcasbin). With this library, Casbin can load policy from Redis or save policy to it.
## Installation
```xml
org.casbin
redis-adapter
1.0.0
```## Simple Example
```java
package org.casbin.adapter;import org.casbin.jcasbin.main.Enforcer;
public class Main {
public static void main(String[] args) {
// Initialize a Redis adapter and use it in a jCasbin enforcer:
RedisAdapter a = new RedisAdapter("localhost", 6379);// Use the following if Redis has password like "123"
// RedisAdapter a = new RedisAdapter("localhost", 6379, "123");// Use the following if Redis has username like "default" and password like "123"
// RedisAdapter a = new RedisAdapter("localhost", 6379, "default", "123");Enforcer e = new Enforcer("examples/rbac_model.conf", a);
// Load the policy from DB.
e.loadPolicy();// Check the permission.
e.enforce("alice", "data1", "read");// Modify the policy.
// e.addPolicy(...);
// e.removePolicy(...);// Save the policy back to DB.
e.savePolicy();
}
}
```## Getting Help
- [jCasbin](https://github.com/casbin/jcasbin)
## License
This project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.