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

Method addPolicies

internal_api.go:403–420  ·  view source on GitHub ↗

addPolicies adds rules to the current policy. If autoRemoveRepeat == true, existing rules are automatically filtered Otherwise, false is returned directly.

(sec string, ptype string, rules [][]string, autoRemoveRepeat bool)

Source from the content-addressed store, hash-verified

401// If autoRemoveRepeat == true, existing rules are automatically filtered
402// Otherwise, false is returned directly.
403func (e *Enforcer) addPolicies(sec string, ptype string, rules [][]string, autoRemoveRepeat bool) (bool, error) {
404 ok, err := e.addPoliciesWithoutNotify(sec, ptype, rules, autoRemoveRepeat)
405 if !ok || err != nil {
406 return ok, err
407 }
408
409 if e.shouldNotify() {
410 var err error
411 if watcher, ok := e.watcher.(persist.WatcherEx); ok {
412 err = watcher.UpdateForAddPolicies(sec, ptype, rules...)
413 } else {
414 err = e.watcher.Update()
415 }
416 return true, err
417 }
418
419 return true, nil
420}
421
422// removePolicy removes a rule from the current policy.
423func (e *Enforcer) removePolicy(sec string, ptype string, rule []string) (bool, error) {

Callers 4

AddNamedPoliciesMethod · 0.95
AddNamedPoliciesExMethod · 0.95

Calls 4

shouldNotifyMethod · 0.95
UpdateForAddPoliciesMethod · 0.65
UpdateMethod · 0.65

Tested by

no test coverage detected