Resolve casbin policies not applied when add user to group
Recently, my team and I struggle with the issue that user cannot execute certain actions even he/she is added to the user group that contains all the actions needed. Let’s see how to fix this.
Before applying the solution , it shows 401 error when user execute certain action:
The solution is applying EnableAutoSave from casbin
Here is what documented from enforcer.go in casbin
// EnableAutoSave controls whether to save a policy rule automatically to the adapter when it is added or removed.func (e *Enforcer) EnableAutoSave(autoSave bool) {e.autoSave = autoSave}
After applying this , the issue no longer happens.
~~Happy coding guys~~