MCPcopy
hub / github.com/apache/casbin / initRmMap

Method initRmMap

enforcer.go:583–608  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

581}
582
583func (e *Enforcer) initRmMap() {
584 for ptype, assertion := range e.model["g"] {
585 if rm, ok := e.rmMap[ptype]; ok {
586 _ = rm.Clear()
587 continue
588 }
589 if len(assertion.Tokens) <= 2 && len(assertion.ParamsTokens) == 0 {
590 assertion.RM = defaultrolemanager.NewRoleManagerImpl(10)
591 e.rmMap[ptype] = assertion.RM
592 }
593 if len(assertion.Tokens) <= 2 && len(assertion.ParamsTokens) != 0 {
594 assertion.CondRM = defaultrolemanager.NewConditionalRoleManager(10)
595 e.condRmMap[ptype] = assertion.CondRM
596 }
597 if len(assertion.Tokens) > 2 {
598 if len(assertion.ParamsTokens) == 0 {
599 assertion.RM = defaultrolemanager.NewRoleManager(10)
600 e.rmMap[ptype] = assertion.RM
601 } else {
602 assertion.CondRM = defaultrolemanager.NewConditionalDomainManager(10)
603 e.condRmMap[ptype] = assertion.CondRM
604 }
605 e.registerDomainMatchingFunc(ptype)
606 }
607 }
608}
609
610// EnableEnforce changes the enforcing state of Casbin, when Casbin is disabled, all access will be allowed by the Enforce() function.
611func (e *Enforcer) EnableEnforce(enable bool) {

Callers 3

loadFilteredPolicyCtxMethod · 0.95
initializeMethod · 0.95
loadFilteredPolicyMethod · 0.95

Calls 2

ClearMethod · 0.65

Tested by

no test coverage detected