Skip to content

Conversation

@yiev
Copy link

@yiev yiev commented Sep 24, 2025

I got the following situation:

  • Microservice architecture
  • using casbin with casbin-mongoose-adapter (SyncedAdapter) and @casbin/mongo-changestream-watcher
  • autoSave=true

Now when microservice A adds a new policy via the addPolicy() method of the Enforcer the following happens:

  • All other microservices become a notification via the mongodb changestream watcher
    • now here I want to add the new policy only to the locally held policy and NOT via the adapter (as it already exists in the MongoDB). With the currently available methods I can only add the policy triggering an endless loop (adding more and more duplicates of the already existing policy) OR I can reload the complete policy on each received change by the watcher, but that's not really a good idea if you got several hundred (micro)services that try this at the same time on every change to the policy.

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

Evren Yildiz added 4 commits September 23, 2025 16:46
…ating and removing policies;

ManagementEnforcer: added methods for adding, updating and removing policies only locally (without usage of adapter)
@CLAassistant
Copy link

CLAassistant commented Sep 24, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ yiev
❌ Evren Yildiz


Evren Yildiz seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@yiev
Copy link
Author

yiev commented Sep 24, 2025

Closing pull request because of failing checks. Will recreate it in a few minutes.

@yiev yiev closed this Sep 24, 2025
@hsluoyz hsluoyz reopened this Sep 24, 2025
@hsluoyz
Copy link
Member

hsluoyz commented Sep 29, 2025

@yiev fix:

image image

@yiev
Copy link
Author

yiev commented Sep 29, 2025

@hsluoyz That's why I initially created the other PR (#505) and closed this one. Can't fix that in this PR, because there was no correct email in my git config for the first commits. Shall I close this PR again and create a new one?

@hsluoyz
Copy link
Member

hsluoyz commented Sep 29, 2025

Replaced by: #505

@hsluoyz hsluoyz closed this Sep 29, 2025
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

Successfully merging this pull request may close these issues.

3 participants