본문으로 건너뛰기

Effector

Effect는 정책 규칙의 결과(허용 또는 거부)입니다. Effector 인터페이스는 enforcer가 여러 일치하는 효과를 단일 결정으로 결합하는 방식을 정의합니다.

MergeEffects()​

MergeEffects()는 일치하는 정책들의 모든 효과를 받아 최종 허용/거부 결과를 생성합니다.

Effect, explainIndex, err = e.MergeEffects(expr, effects, matches, policyIndex, policyLength)

매개변수:

매개변수설명
expr정책 효과 표현식 문자열(예: 모델에서 가져옴).
effects효과 슬라이스: Allow, Deny 또는 Indeterminate.
matches일치한 정책 인덱스.
policyIndex현재 정책 인덱스.
policyLength총 정책 수.

반환 값:

  • Effect — 최종 결정(Allow, Deny 또는 Indeterminate).
  • explainIndex — 결과를 결정한 정책의 인덱스(해당 없는 경우 -1).
  • err — effector가 표현식을 지원하지 않는 경우 nil이 아닌 값.

사용자 지정 Effector 사용:

var e Effector
Effect, explainIndex, err = e.MergeEffects(expr, effects, matches, policyIndex, policyLength)

표준 allow-override 효과의 경우, 일치하는 정책 중 하나라도 허용하고 거부가 없으면 결과는 허용입니다. 사용자 지정 effector는 다른 의미론(예: deny-override, priority)을 구현합니다.

노트

효과 표현식이 priority(p_eft) || deny가 아닌 한, enforcer는 단락 평가(short-circuit)할 수 있습니다: 결과가 결정되면 나머지 정책은 평가되지 않습니다. 따라서 policyIndex < policyLength-1일 때 일부 효과가 건너뛰어질 수 있습니다.

Comments are powered by giscus and GitHub Discussions. They load from giscus.app and GitHub only after you click the button below.