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

Method RemoveFilteredPolicySelf

enforcer_distributed.go:97–121  ·  view source on GitHub ↗

RemoveFilteredPolicySelf provides a method for dispatcher to remove an authorization rule from the current policy, field filters can be specified. The function returns the rules affected and error.

(shouldPersist func() bool, sec string, ptype string, fieldIndex int, fieldValues ...string)

Source from the content-addressed store, hash-verified

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.
97func (d *DistributedEnforcer) RemoveFilteredPolicySelf(shouldPersist func() bool, sec string, ptype string, fieldIndex int, fieldValues ...string) (affected [][]string, err error) {
98 d.m.Lock()
99 defer d.m.Unlock()
100 if shouldPersist != nil && shouldPersist() {
101 if err = d.adapter.RemoveFilteredPolicy(sec, ptype, fieldIndex, fieldValues...); err != nil {
102 if err.Error() != notImplemented {
103 return nil, err
104 }
105 }
106 }
107
108 _, affected, err = d.model.RemoveFilteredPolicy(sec, ptype, fieldIndex, fieldValues...)
109 if err != nil {
110 return affected, err
111 }
112
113 if sec == "g" {
114 err := d.BuildIncrementalRoleLinks(model.PolicyRemove, ptype, affected)
115 if err != nil {
116 return affected, err
117 }
118 }
119
120 return affected, nil
121}
122
123// ClearPolicySelf provides a method for dispatcher to clear all rules from the current policy.
124func (d *DistributedEnforcer) ClearPolicySelf(shouldPersist func() bool) error {

Callers

nothing calls this directly

Calls 3

RemoveFilteredPolicyMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected