{"id":19298196,"url":"https://github.com/casbin/redis-watcher","last_synced_at":"2026-01-16T07:29:05.963Z","repository":{"id":37427940,"uuid":"357931123","full_name":"casbin/redis-watcher","owner":"casbin","description":"Redis WatcherEx for Casbin","archived":false,"fork":false,"pushed_at":"2026-01-13T18:16:30.000Z","size":55,"stargazers_count":44,"open_issues_count":3,"forks_count":40,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-13T19:24:53.972Z","etag":null,"topics":["abac","access-control","acl","auth","authorization","authz","casbin","go","golang","rbac","redis","watcher","watcherex"],"latest_commit_sha":null,"homepage":"https://github.com/casbin/casbin","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/casbin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"casbin"}},"created_at":"2021-04-14T14:18:14.000Z","updated_at":"2026-01-13T18:04:48.000Z","dependencies_parsed_at":"2023-01-20T21:18:24.762Z","dependency_job_id":null,"html_url":"https://github.com/casbin/redis-watcher","commit_stats":{"total_commits":23,"total_committers":15,"mean_commits":"1.5333333333333334","dds":0.782608695652174,"last_synced_commit":"fed3072b6a37d997bc3fb08543162154487c4db4"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/casbin/redis-watcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fredis-watcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fredis-watcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fredis-watcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fredis-watcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/casbin","download_url":"https://codeload.github.com/casbin/redis-watcher/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fredis-watcher/sbom","scorecard":{"id":267055,"data":{"date":"2025-08-11","repo":{"name":"github.com/casbin/redis-watcher","commit":"fed3072b6a37d997bc3fb08543162154487c4db4"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.5,"checks":[{"name":"Code-Review","score":9,"reason":"Found 18/20 approved changesets -- score normalized to 9","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/casbin/redis-watcher/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/casbin/redis-watcher/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/casbin/redis-watcher/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:56: update your workflow using https://app.stepsecurity.io/secureworkflow/casbin/redis-watcher/ci.yml/master?enable=pin","Warn: goCommand not pinned by hash: .github/workflows/ci.yml:41","Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:62","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 goCommand dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/ci.yml:47"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2025-3540"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 28 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T12:21:39.137Z","repository_id":37427940,"created_at":"2025-08-17T12:21:39.137Z","updated_at":"2025-08-17T12:21:39.137Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abac","access-control","acl","auth","authorization","authz","casbin","go","golang","rbac","redis","watcher","watcherex"],"created_at":"2024-11-09T23:07:14.000Z","updated_at":"2026-01-16T07:29:05.946Z","avatar_url":"https://github.com/casbin.png","language":"Go","funding_links":["https://github.com/sponsors/casbin"],"categories":[],"sub_categories":[],"readme":"Redis Watcher\n====\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/casbin/redis-watcher)](https://goreportcard.com/report/github.com/casbin/redis-watcher)\n[![Go](https://github.com/casbin/redis-watcher/actions/workflows/ci.yml/badge.svg)](https://github.com/casbin/redis-watcher/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/casbin/redis-watcher/badge.svg?branch=master)](https://coveralls.io/github/casbin/redis-watcher?branch=master)\n[![Godoc](https://godoc.org/github.com/casbin/redis-watcher?status.svg)](https://godoc.org/github.com/casbin/redis-watcher)\n[![Release](https://img.shields.io/github/release/casbin/redis-watcher.svg)](https://github.com/casbin/redis-watcher/releases/latest)\n[![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord\u0026label=discord\u0026color=5865F2)](https://discord.gg/S5UjpzGZjN)\n[![Sourcegraph](https://sourcegraph.com/github.com/casbin/redis-watcher/-/badge.svg)](https://sourcegraph.com/github.com/casbin/redis-watcher?badge)\n\nRedis Watcher is a [Redis](http://redis.io) watcher for [Casbin](https://github.com/casbin/casbin).\n\n## Installation\n\n```bash\ngo get github.com/casbin/redis-watcher/v2\n```\n\n## Simple Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/casbin/casbin/v3\"\n\trediswatcher \"github.com/casbin/redis-watcher/v2\"\n\t\"github.com/redis/go-redis/v9\"\n)\n\nfunc updateCallback(msg string) {\n\tlog.Println(msg)\n}\n\nfunc main() {\n\t// Initialize the watcher.\n\t// Use the Redis host as parameter.\n\tw, _ := rediswatcher.NewWatcher(\"localhost:6379\", rediswatcher.WatcherOptions{\n\t\tOptions: redis.Options{\n\t\t\tNetwork:  \"tcp\",\n\t\t\tPassword: \"\",\n\t\t},\n\t\tChannel:    \"/casbin\",\n\t\t// Only exists in test, generally be true\n\t\tIgnoreSelf: false,\n\t})\n\n\t// Or initialize the watcher in redis cluster.\n\t// w, _ := rediswatcher.NewWatcherWithCluster(\"localhost:6379,localhost:6379,localhost:6379\", rediswatcher.WatcherOptions{\n\t// \tClusterOptions: redis.ClusterOptions{\n\t// \t\tPassword: \"\",\n\t// \t},\n\t// \tChannel: \"/casbin\",\n\t// \tIgnoreSelf: false,\n\t// })\n\n\t// Initialize the enforcer.\n\te, _ := casbin.NewEnforcer(\"examples/rbac_model.conf\", \"examples/rbac_policy.csv\")\n\n\t// Set the watcher for the enforcer.\n\t_ = e.SetWatcher(w)\n\n\t// Set callback to local example\n\t_ = w.SetUpdateCallback(updateCallback)\n\t\n\t// Or use the default callback\n\t// _ = w.SetUpdateCallback(rediswatcher.DefaultUpdateCallback(e))\n\n\t// Update the policy to test the effect.\n\t// You should see \"[casbin rules updated]\" in the log.\n\t_ = e.SavePolicy()\n\t// Only exists in test\n\tfmt.Scanln()\n}\n\n```\n\n## Using Existing Redis Client\n\nIf you already have an existing Redis client instance (e.g., due to restricted access to connection details or centralized Redis setup), you can reuse it to create a watcher.\n\n### With Regular Redis Client\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/casbin/casbin/v3\"\n\trediswatcher \"github.com/casbin/redis-watcher/v2\"\n\t\"github.com/redis/go-redis/v9\"\n)\n\nfunc main() {\n\t// Create your own Redis client\n\tredisClient := redis.NewClient(\u0026redis.Options{\n\t\tAddr:     \"localhost:6379\",\n\t\tPassword: \"\",\n\t\tDB:       0,\n\t})\n\n\t// Initialize the watcher with existing client\n\t// Pass empty string for addr since the SubClient and PubClient are already provided\n\tw, _ := rediswatcher.NewWatcher(\"\", rediswatcher.WatcherOptions{\n\t\tSubClient: redisClient,\n\t\tPubClient: redisClient,\n\t\tChannel:   \"/casbin\",\n\t})\n\n\t// Initialize the enforcer.\n\te, _ := casbin.NewEnforcer(\"examples/rbac_model.conf\", \"examples/rbac_policy.csv\")\n\n\t// Set the watcher for the enforcer.\n\t_ = e.SetWatcher(w)\n\n\t// Set callback\n\t_ = w.SetUpdateCallback(rediswatcher.DefaultUpdateCallback(e))\n\n\t// Update the policy to test the effect.\n\t_ = e.SavePolicy()\n\tfmt.Scanln()\n}\n```\n\n### With Redis Cluster Client\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/casbin/casbin/v3\"\n\trediswatcher \"github.com/casbin/redis-watcher/v2\"\n\t\"github.com/redis/go-redis/v9\"\n)\n\nfunc main() {\n\t// Create your own Redis cluster client\n\tclusterClient := redis.NewClusterClient(\u0026redis.ClusterOptions{\n\t\tAddrs:    []string{\"localhost:7000\", \"localhost:7001\", \"localhost:7002\"},\n\t\tPassword: \"\",\n\t})\n\n\t// Initialize the watcher with existing cluster client\n\t// Pass empty string for addrs since the SubClient and PubClient are already provided\n\tw, _ := rediswatcher.NewWatcherWithCluster(\"\", rediswatcher.WatcherOptions{\n\t\tSubClient: clusterClient,\n\t\tPubClient: clusterClient,\n\t\tChannel:   \"/casbin\",\n\t})\n\n\t// Initialize the enforcer.\n\te, _ := casbin.NewEnforcer(\"examples/rbac_model.conf\", \"examples/rbac_policy.csv\")\n\n\t// Set the watcher for the enforcer.\n\t_ = e.SetWatcher(w)\n\n\t// Set callback\n\t_ = w.SetUpdateCallback(rediswatcher.DefaultUpdateCallback(e))\n\n\t// Update the policy to test the effect.\n\t_ = e.SavePolicy()\n\tfmt.Scanln()\n}\n```\n\n## Getting Help\n\n- [Casbin](https://github.com/casbin/casbin)\n- [go-redis](https://github.com/go-redis/redis)\n\n## License\n\nThis project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasbin%2Fredis-watcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcasbin%2Fredis-watcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasbin%2Fredis-watcher/lists"}