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)
| 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. |
| 97 | func (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. |
| 124 | func (d *DistributedEnforcer) ClearPolicySelf(shouldPersist func() bool) error { |
nothing calls this directly
no test coverage detected