registerDomainMatchingFunc registers domain matching function if the matcher uses keyMatch for domains.
(ptype string)
| 565 | |
| 566 | // registerDomainMatchingFunc registers domain matching function if the matcher uses keyMatch for domains. |
| 567 | func (e *Enforcer) registerDomainMatchingFunc(ptype string) { |
| 568 | // Dynamically detect the domain token name from the model definition. |
| 569 | // In RBAC with domains, the domain is typically the second parameter (index 1) |
| 570 | // in both request and policy definitions (e.g., r = sub, dom, obj, act). |
| 571 | // We extract the actual token names to support arbitrary domain parameter names. |
| 572 | rDomainToken, pDomainToken := e.getDomainTokens() |
| 573 | if rDomainToken == "" || pDomainToken == "" { |
| 574 | return |
| 575 | } |
| 576 | |
| 577 | matchFun := fmt.Sprintf("keyMatch(%s, %s)", rDomainToken, pDomainToken) |
| 578 | if strings.Contains(e.model["m"]["m"].Value, matchFun) { |
| 579 | e.AddNamedDomainMatchingFunc(ptype, "g", util.KeyMatch) |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | func (e *Enforcer) initRmMap() { |
| 584 | for ptype, assertion := range e.model["g"] { |
no test coverage detected