8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
(*SyncedEnforcer).LoadPolicyFast do not inherit the previous RoleManager's MatchingFunc because it rebuilds all RoleManagers.
(*SyncedEnforcer).LoadPolicyFast
// LoadPolicyFast is not blocked when adapter calls LoadPolicy. func (e *SyncedEnforcer) LoadPolicyFast() error { ... if e.autoBuildRoleLinks { for ptype := range newModel["g"] { newRmMap[ptype] = defaultrolemanager.NewRoleManager(10) } err = newModel.BuildRoleLinks(newRmMap) if err != nil { return err } } ... }
Compare to (*Enforcer).LoadPolicy(which maintains RoleManager's MatchingFunc):
(*Enforcer).LoadPolicy
func (e *Enforcer) LoadPolicy() error { ... if e.autoBuildRoleLinks { needToRebuild = true if err := e.rebuildRoleLinks(newModel); err != nil { return err } if err := e.rebuildConditionalRoleLinks(newModel); err != nil { return err } } ... } func (e *Enforcer) rebuildRoleLinks(newModel model.Model) error { if len(e.rmMap) != 0 { for _, rm := range e.rmMap { err := rm.Clear() if err != nil { return err } } err := newModel.BuildRoleLinks(e.rmMap) if err != nil { return err } } return nil }
(*SyncedEnforcer).LoadPolicyFast maintains all RoleManager's MatchingFunc.
RoleManager's MatchingFunc lost after calling (*SyncedEnforcer).LoadPolicyFast, which could cause enforce fail.
The text was updated successfully, but these errors were encountered:
@tangyang9464 @JalinWang
Sorry, something went wrong.
I'm having the same problem right now. But I use the trick way to avoid it.
e, err := genEnforcer(db) if err != nil { log.WithField("err", err.Error()).Error("New casbin enforcer error.") return } E.GetLock().Lock() defer E.GetLock().Unlock() E.Enforcer = e.Enforcer
hsluoyz
No branches or pull requests
Describe the bug
(*SyncedEnforcer).LoadPolicyFast
do not inherit the previous RoleManager's MatchingFunc because it rebuilds all RoleManagers.Compare to
(*Enforcer).LoadPolicy
(which maintains RoleManager's MatchingFunc):Expected behavior
(*SyncedEnforcer).LoadPolicyFast
maintains all RoleManager's MatchingFunc.Actual behavior
RoleManager's MatchingFunc lost after calling (*SyncedEnforcer).LoadPolicyFast, which could cause enforce fail.
The text was updated successfully, but these errors were encountered: