https://github.com/jcasbin/redis-watcher-ex
Redis WatcherEx for jCasbin
https://github.com/jcasbin/redis-watcher-ex
abac acl auth authorization authz casbin java jcasbin rbac redis watcher watcherex
Last synced: 23 days ago
JSON representation
Redis WatcherEx for jCasbin
- Host: GitHub
- URL: https://github.com/jcasbin/redis-watcher-ex
- Owner: jcasbin
- License: apache-2.0
- Created: 2023-06-07T18:25:18.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-02T09:14:19.000Z (7 months ago)
- Last Synced: 2025-03-27T17:51:55.302Z (about 1 month ago)
- Topics: abac, acl, auth, authorization, authz, casbin, java, jcasbin, rbac, redis, watcher, watcherex
- Language: Java
- Homepage: https://github.com/casbin/jcasbin
- Size: 21.5 KB
- Stars: 0
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Redis WatcherEx
====[](https://github.com/jcasbin/redis-waycher-ex/actions/workflows/ci.yml)
[](https://central.sonatype.com/artifact/org.casbin/jcasbin-redis-watcher-ex)---
## Installation
For Maven:
```xmlorg.casbin
jcasbin-redis-watcher-ex
1.1.0```
## Simple Example```java
package org.casbin.watcherEx;import io.lettuce.core.RedisURI;
import org.casbin.jcasbin.main.Enforcer;public class Main {
public static void main(String[] args) {
// Initialize the RedisWatcher.
// Use the Redis host and port as parameters.
WatcherOptions options = new WatcherOptions();
options.setChannel("jcasbin-channel");
options.setOptions(RedisURI.builder().withHost("your ip").withPort(6379).build());RedisWatcherEx redisWatcherEx = new RedisWatcherEx(options);
// Set the update callback.
redisWatcherEx.setUpdateCallback((msg) ->{
System.out.println(msg);
});// Initialize the JCasbin enforcer.
Enforcer enforcer = new Enforcer("examples/rbac_model.conf", "examples/rbac_policy.csv");
// Set the watcher for the enforcer.
enforcer.setWatcher(redisWatcherEx);// Update the policy to test the effect.
// You should see "[casbin rules updated]" in the log.
enforcer.savePolicy();// Only exists in test (Wait for input to keep the program running)
Scanner scanner = new Scanner(System.in);
scanner.nextLine();
}
}
```## 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.