()
| 581 | } |
| 582 | |
| 583 | func (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. |
| 611 | func (e *Enforcer) EnableEnforce(enable bool) { |
no test coverage detected