Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto-loading of new policies #9

Open
mattbishop opened this issue Sep 14, 2021 · 6 comments
Open

Add auto-loading of new policies #9

mattbishop opened this issue Sep 14, 2021 · 6 comments

Comments

@mattbishop
Copy link

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

@hsluoyz
Copy link

hsluoyz commented Sep 14, 2021

@mattbishop you can use watchers: https://casbin.org/docs/en/watchers

@SomaticIT
Copy link
Contributor

@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.

@mattbishop
Copy link
Author

mattbishop commented Sep 14, 2021 via email

@hsluoyz
Copy link

hsluoyz commented Sep 14, 2021

Then you have to implement the feature in this repo.

ping @nodece @Zxilly @Gabriel-403

@SomaticIT
Copy link
Contributor

I agree to have a Watcher implementation in this repo:

  1. Create a watcher.ts file in lib
  2. Implement the Watcher interface from casbin
  3. Export the 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.

@mattbishop
Copy link
Author

mattbishop commented Sep 15, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants