{"id":29089589,"url":"https://github.com/jcasbin/jcasbin-postgres-watcher","last_synced_at":"2025-06-28T04:04:11.796Z","repository":{"id":301070265,"uuid":"1005613706","full_name":"jcasbin/jcasbin-postgres-watcher","owner":"jcasbin","description":"PostgreSQL adapter for Casbin","archived":false,"fork":false,"pushed_at":"2025-06-25T01:36:41.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-25T02:36:24.220Z","etag":null,"topics":["adapter","auth","authorization","authz","casbin","database","java","jcasbin","middleware","pg","postgres","postgresql","storage-driver"],"latest_commit_sha":null,"homepage":"https://github.com/casbin/jcasbin","language":"Java","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/jcasbin.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-20T14:08:41.000Z","updated_at":"2025-06-25T01:36:43.000Z","dependencies_parsed_at":"2025-06-25T02:37:35.751Z","dependency_job_id":"855d014f-89ff-47fd-883e-61c9c879865e","html_url":"https://github.com/jcasbin/jcasbin-postgres-watcher","commit_stats":null,"previous_names":["jcasbin/jcasbin-postgres-watcher"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jcasbin/jcasbin-postgres-watcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcasbin%2Fjcasbin-postgres-watcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcasbin%2Fjcasbin-postgres-watcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcasbin%2Fjcasbin-postgres-watcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcasbin%2Fjcasbin-postgres-watcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcasbin","download_url":"https://codeload.github.com/jcasbin/jcasbin-postgres-watcher/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcasbin%2Fjcasbin-postgres-watcher/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262371684,"owners_count":23300595,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["adapter","auth","authorization","authz","casbin","database","java","jcasbin","middleware","pg","postgres","postgresql","storage-driver"],"created_at":"2025-06-28T04:04:08.600Z","updated_at":"2025-06-28T04:04:11.778Z","avatar_url":"https://github.com/jcasbin.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jcasbin-postgres-watcher\n\n[![GitHub Actions](https://github.com/jcasbin/jcasbin-postgres-watcher/actions/workflows/ci.yml/badge.svg)](https://github.com/jcasbin/jcasbin-postgres-watcher/actions/workflows/ci.yml)\n![License](https://img.shields.io/github/license/jcasbin/jcasbin-postgres-watcher)\n[![Javadoc](https://javadoc.io/badge2/org.casbin/jcasbin-postgres-watcher/javadoc.svg)](https://javadoc.io/doc/org.casbin/jcasbin-postgres-watcher)\n[![Maven Central](https://img.shields.io/maven-central/v/org.casbin/jcasbin-postgres-watcher.svg)](https://mvnrepository.com/artifact/org.casbin/jcasbin-postgres-watcher/latest)\n[![Release](https://img.shields.io/github/release/jcasbin/jcasbin-postgres-watcher.svg)](https://github.com/jcasbin/jcasbin-postgres-watcher/releases/latest)\n[![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord\u0026label=discord\u0026color=5865F2)](https://discord.gg/S5UjpzGZjN)\n\njCasbin PostgreSQL Watcher is a [PostgreSQL](https://www.postgresql.org/) watcher for [jCasbin](https://github.com/casbin/jcasbin).\n\n## Installation\n\n**For Maven**\n\n ```\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.casbin\u003c/groupId\u003e\n    \u003cartifactId\u003ejcasbin-postgres-watcher\u003c/artifactId\u003e\n    \u003cversion\u003e1.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n ```\n\n## Simple Example\n\nif you have two casbin instances A and B\n\n**A:**  **Producer**\n\n```java\n// Initialize PostgreSQL Watcher\nString channel = \"casbin_channel\";\nJCasbinPostgresWatcher watcher = new JCasbinPostgresWatcher(\n    \"jdbc:postgresql://localhost:5432/your_db\",\n    \"postgres\",\n    \"your_password\",\n    channel\n);\n// Support for advanced configuration with WatcherConfig\n// WatcherConfig config = new WatcherConfig();\n// config.setChannel(channel);\n// config.setVerbose(true);\n// config.setLocalId(\"instance-1\");\n// JCasbinPostgresWatcher watcher = new JCasbinPostgresWatcher(url, user, password, config);\n\nEnforcer enforcer = new SyncedEnforcer(\"examples/rbac_model.conf\", \"examples/rbac_policy.csv\");\nenforcer.setWatcher(watcher);\n\n// The following code is not necessary and generally does not need to be written unless you understand what you want to do\n/*\nRunnable updateCallback = () -\u003e {\n    // Custom behavior\n};\nwatcher.setUpdateCallback(updateCallback);\n*/\n\n// Modify policy, it will notify B\nenforcer.addPolicy(...);\n\n// Using WatcherEx specific methods for fine-grained policy updates\n// Add a policy\nenforcer.addPolicy(...);\nwatcher.updateForAddPolicy(...);\n\n```\n\n**B:** **Consumer**\n\n````Java\n// Initialize PostgreSQL Watcher with same channel\nString channel = \"casbin_channel\";\nJCasbinPostgresWatcher watcher = new JCasbinPostgresWatcher(\n    \"jdbc:postgresql://localhost:5432/your_db\",\n    \"postgres\",\n    \"your_password\",\n    channel\n);\n\nEnforcer enforcer = new SyncedEnforcer(\"examples/rbac_model.conf\", \"examples/rbac_policy.csv\");\nenforcer.setWatcher(watcher);\n// B set watcher and subscribe to the same channel, then it will receive the notification of A, and then call LoadPolicy to reload policy\n````\n\n## Getting Help\n\n- [jCasbin](https://github.com/casbin/jCasbin)\n- [pgjdbc](https://github.com/pgjdbc/pgjdbc)\n\n## License\n\nThis project is under Apache 2.0 License. See the [LICENSE](https://github.com/jcasbin/redis-watcher/blob/master/LICENSE) file for the full license text.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcasbin%2Fjcasbin-postgres-watcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcasbin%2Fjcasbin-postgres-watcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcasbin%2Fjcasbin-postgres-watcher/lists"}