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

Function GenerateConditionalGFunction

util/builtin_operators.go:448–465  ·  view source on GitHub ↗

GenerateConditionalGFunction is the factory method of the g(_, _[, _]) function with conditions.

(crm rbac.ConditionalRoleManager)

Source from the content-addressed store, hash-verified

446
447// GenerateConditionalGFunction is the factory method of the g(_, _[, _]) function with conditions.
448func GenerateConditionalGFunction(crm rbac.ConditionalRoleManager) govaluate.ExpressionFunction {
449 return func(args ...interface{}) (interface{}, error) {
450 // Like all our other govaluate functions, all args are strings.
451 var hasLink bool
452
453 name1, name2 := args[0].(string), args[1].(string)
454 if crm == nil {
455 hasLink = name1 == name2
456 } else if len(args) == 2 {
457 hasLink, _ = crm.HasLink(name1, name2)
458 } else {
459 domain := args[2].(string)
460 hasLink, _ = crm.HasLink(name1, name2, domain)
461 }
462
463 return hasLink, nil
464 }
465}
466
467// builtin LinkConditionFunc
468

Callers 2

enforceMethod · 0.92

Calls 1

HasLinkMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…