casbin / jcasbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Java
https://casbin.org
Apache License 2.0
2.38k stars 461 forks source link

savePolicies and removePolicies are not synchronised #290

Closed damienmiheev closed 2 years ago

damienmiheev commented 2 years ago

I'm using latest version 1.27.0 of jcasbin and postgres db, so adapter supports batchUpdate. I was struggling with concurrent update of policies.

I've just realised that SyncedEnforcer has no representative version savePolicies and removePolicies methods, so ManagementEnforcer was used instead, and it is not thread safe.

Is there any reason of why SyncedEnforcer has no such methods? Should i manually iterate through the list and save my policies one by one instead?

Is it possible to add synchronised versions of those methods into SyncedEnforcer?

casbin-bot commented 2 years ago

@tangyang9464 @imp2002

hsluoyz commented 2 years ago

@damienmiheev can you make a PR to add them?