feat: Added methods to enforcer for adding, removing and updating policies without usage of adapter (even if autoSave is true)#505
Conversation
…icies without usage of adapter (even if autoSave is true)
|
In my own repo the checks were all successful: Don't know why coveralls is failing here... |
|
@yiev then don't use watcher, why use watcher and then disable it? |
|
@hsluoyz Thank you for your really fast response! 😸 I need the watcher to keep the policy up to date across all microservices. Maybe it gets a bit clearer with a bit more detailed example of what happens right now: Microservice A adds a new policy via So the updateCallback function of the watcher in all three microservices is called. In this function I could just reload the whole policy via
So I wanted a method for adding policies, that does not call I hope now it makes sense, why I want these newly added methods? Or am I missing something and my approach does not make any sense? |
|
@yiev first create issue to discuss before making PR |
|
@yiev don't do code formatting in this same PR. Did your solution come from Golang Casbin? |
|
@hsluoyz No, the solution was my own idea. I didn't work with Golang Casbin yet, but I just checked the repo of Golang Casbin and the same behaviour is given there also (at least as far as I can say from just looking for some minutes into it). So I would have the same problem with Golang Casbin with my architecture. |
I got the following situation:
casbin-mongoose-adapter(SyncedAdapter) and@casbin/mongo-changestream-watcherautoSaveistrueNow when microservice A adds a new policy via the addPolicy() method of the Enforcer the following happens:
The situation is also similar for updating or deleting policies with the described setup and configuration.
I need methods for adding, updating and deleting policies without persisting them via the adapter - even if autoSave is true.
So I created this pull request here. 😃 I would be glad if a maintainer could have a look on it. 😃