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

Method addConditionalRoleLink

model/assertion.go:150–165  ·  view source on GitHub ↗

addConditionalRoleLink adds Link to rbac.ConditionalRoleManager and sets the parameters for LinkConditionFunc.

(rule []string, domainRule []string)

Source from the content-addressed store, hash-verified

148
149// addConditionalRoleLink adds Link to rbac.ConditionalRoleManager and sets the parameters for LinkConditionFunc.
150func (ast *Assertion) addConditionalRoleLink(rule []string, domainRule []string) error {
151 var err error
152 if len(domainRule) == 0 {
153 err = ast.CondRM.AddLink(rule[0], rule[1])
154 if err == nil {
155 ast.CondRM.SetLinkConditionFuncParams(rule[0], rule[1], rule[len(ast.Tokens):]...)
156 }
157 } else {
158 domain := domainRule[0]
159 err = ast.CondRM.AddLink(rule[0], rule[1], domain)
160 if err == nil {
161 ast.CondRM.SetDomainLinkConditionFuncParams(rule[0], rule[1], domain, rule[len(ast.Tokens):]...)
162 }
163 }
164 return err
165}
166
167func (ast *Assertion) copy() *Assertion {
168 tokens := append([]string(nil), ast.Tokens...)

Calls 3

AddLinkMethod · 0.65

Tested by

no test coverage detected