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

Method RemovePoliciesSelf

enforcer_distributed.go:69–93  ·  view source on GitHub ↗

RemovePoliciesSelf provides a method for dispatcher to remove a set of rules from current policy. The function returns the rules affected and error.

(shouldPersist func() bool, sec string, ptype string, rules [][]string)

Source from the content-addressed store, hash-verified

67// RemovePoliciesSelf provides a method for dispatcher to remove a set of rules from current policy.
68// The function returns the rules affected and error.
69func (d *DistributedEnforcer) RemovePoliciesSelf(shouldPersist func() bool, sec string, ptype string, rules [][]string) (affected [][]string, err error) {
70 d.m.Lock()
71 defer d.m.Unlock()
72 if shouldPersist != nil && shouldPersist() {
73 if err = d.adapter.(persist.BatchAdapter).RemovePolicies(sec, ptype, rules); err != nil {
74 if err.Error() != notImplemented {
75 return nil, err
76 }
77 }
78 }
79
80 affected, err = d.model.RemovePoliciesWithAffected(sec, ptype, rules)
81 if err != nil {
82 return affected, err
83 }
84
85 if sec == "g" {
86 err = d.BuildIncrementalRoleLinks(model.PolicyRemove, ptype, affected)
87 if err != nil {
88 return affected, err
89 }
90 }
91
92 return affected, err
93}
94
95// RemoveFilteredPolicySelf provides a method for dispatcher to remove an authorization rule from the current policy, field filters can be specified.
96// The function returns the rules affected and error.

Callers

nothing calls this directly

Calls 4

RemovePoliciesMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected