removeFilteredPolicyWithoutNotifyCtx removes policy rules that match the filter from the current policy with context.
(ctx context.Context, sec string, ptype string, fieldIndex int, fieldValues []string)
| 549 | |
| 550 | // removeFilteredPolicyWithoutNotifyCtx removes policy rules that match the filter from the current policy with context. |
| 551 | func (e *ContextEnforcer) removeFilteredPolicyWithoutNotifyCtx(ctx context.Context, sec string, ptype string, fieldIndex int, fieldValues []string) (bool, error) { |
| 552 | if len(fieldValues) == 0 { |
| 553 | return false, Err.ErrInvalidFieldValuesParameter |
| 554 | } |
| 555 | |
| 556 | if e.dispatcher != nil && e.autoNotifyDispatcher { |
| 557 | return true, e.dispatcher.RemoveFilteredPolicy(sec, ptype, fieldIndex, fieldValues...) |
| 558 | } |
| 559 | |
| 560 | if e.shouldPersist() { |
| 561 | if err := e.adapterCtx.RemoveFilteredPolicyCtx(ctx, sec, ptype, fieldIndex, fieldValues...); err != nil { |
| 562 | if err.Error() != notImplemented { |
| 563 | return false, err |
| 564 | } |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | ruleRemoved, effects, err := e.model.RemoveFilteredPolicy(sec, ptype, fieldIndex, fieldValues...) |
| 569 | if !ruleRemoved || err != nil { |
| 570 | return ruleRemoved, err |
| 571 | } |
| 572 | |
| 573 | if sec == "g" { |
| 574 | err := e.BuildIncrementalRoleLinks(model.PolicyRemove, ptype, effects) |
| 575 | if err != nil { |
| 576 | return ruleRemoved, err |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | return ruleRemoved, nil |
| 581 | } |
| 582 | |
| 583 | // updatePolicyWithoutNotifyCtx updates a policy rule in the current policy with context. |
| 584 | func (e *ContextEnforcer) updatePolicyWithoutNotifyCtx(ctx context.Context, sec string, ptype string, oldRule, newRule []string) (bool, error) { |
no test coverage detected