Open mattbishop opened 2 years ago
@mattbishop you can use watchers: https://casbin.org/docs/en/watchers
@mattbishop, I think the safest way to work on a multi-node configuration is the one @hsluoyz mention. Watchers were built exactly for this purpose.
Thanks, I read about watchers but am hoping to avoid standing up another process for this purpose. I only have node servers next Postgres would be simpler for this task in my situation.
— Matt Bishop
On Sep 14, 2021, at 3:15 AM, Maxime LUCE @.***> wrote:
@mattbishop, I think the safest way to work on a multi-node configuration is the one @hsluoyz mention. Watchers were built exactly for this purpose.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
Then you have to implement the feature in this repo.
ping @nodece @Zxilly @gabriel-403
I agree to have a Watcher
implementation in this repo:
watcher.ts
file in lib
Watcher
interface from casbin
PostgresWatcher
in index.ts
However, if you want to implement this in this repo, you should stick using node-postgres.
Maybe the simplest way would be to create another repo and package using pg-listen.
I like this approach! I won't be able to get to it until October or November so please keep recording your thoughts in this ticket.
On Wed, Sep 15, 2021 at 2:09 PM Maxime LUCE @.***> wrote:
I agree to have a Watcher implementation in this repo:
- Create a watcher.ts file in lib
- Implement the Watcher interface from casbin
- Export the PostgresWatcher in index.ts
However, if you want to implement this in this repo, you should stick using node-postgres https://node-postgres.com/.
Maybe the simplest way would be to create another repo and package using pg-listen https://www.npmjs.com/package/pg-listen.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/touchifyapp/casbin-pg-adapter/issues/9#issuecomment-920377455, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACY3BO63JKIBLWSWNWG5DTUCEDPXANCNFSM5D7H3LVA .
When Casbin is used in a multi-node configuration, one node may change the Casbin configuration, yet the others are unaware of this change. It would be possible for all nodes to use Postgres' LISTEN/NOTIFY feature to listen for changes on the tables and reload their policies as they change.
See https://www.postgresql.org/docs/current/sql-listen.html