SAPL Policy Set

While a policy can either be a top-level SAPL document or be contained in a policy set, policy sets are always top-level documents. For evaluating an authorization subscription, the PDP evaluates existing policy sets. Policy sets are evaluated against an authorization subscription by checking their target expression, if applicable, evaluating their policies, and combining multiple votes according to a combining algorithm specified in the policy set. Finally, similarly to policies, policy sets vote PERMIT, DENY, SUSPEND, NOT_APPLICABLE, or INDETERMINATE.

Policy sets are used to structure multiple policies and provide an order for the policies they contain. Hence, their policies can be evaluated one after another.

A policy set definition starts with the keyword set.

Name

The keyword set is followed by the policy set name. The name is a string identifying the policy set. It must be unique within all policy sets and policies.

Combining Algorithm

The name is followed by a combining algorithm that specifies how the policy set resolves its policies’ votes. For example:

set "example-policies" priority deny or deny

Target Expression

After the combining algorithm, an optional target expression can be specified. The target expression is a condition for applying the policy set. It starts with the keyword for followed by an expression that must evaluate to either true or false. To match the set, a subscription must satisfy its enforced schema requirements. If the set declares a target, the target must also evaluate to true.

The policy sets’ target expression is used to select matching policy sets from a large collection of policy documents before evaluating them. As this needs to be done efficiently, there are no attribute finder steps allowed at this place.

Variable Assignments

Set variable assignments follow the optional target expression and precede the policies. The set target, enforced schema declarations, and every policy in the set can refer to these variables. An assignment consists of var, a name, =, an expression, and a semicolon.

A set variable used in the target must follow the target’s restrictions on attribute finders. A set variable used only in policies may use an attribute finder.

A variable declared inside a policy is visible only within that policy. Two policies in the same set may each declare a local variable with the same name. A policy that redeclares a set variable fails to compile.

Policies

Each policy set must contain one or more policies. See above how to describe a SAPL policy. If the combining algorithm uses the first voting style, the policies are evaluated in the order in which they appear in the policy set.

In each policy, functions and attribute finders imported at the beginning of the SAPL document can be used under their shorter name.

Example: First Applicable Policy

The first or deny algorithm evaluates policies in document order and uses the first applicable policy’s vote. This is useful when policies have overlapping conditions and business rules dictate a priority.

Note: This is a fictional scenario to illustrate how policy order can encode business priority.

set "facility access control"
first or deny
for resource.type == "facility"

policy "VIP always allowed"
permit
    subject.id in resource.vipList;

policy "blacklisted users denied"
deny
    subject.id in resource.blacklist;

policy "standard access during business hours"
permit
    <time.localTimeIsBetween("08:00:00", "18:00:00")>;

The policy order encodes business priority: “VIP status trumps blacklist status.”

Scenario Result Reason
VIP who is also blacklisted permit VIP policy checked first
Blacklisted user during business hours deny Blacklist before hours check
Normal user during business hours permit Hours policy applies
Normal user outside business hours deny No policy applies, default is deny

If the blacklist policy came first, VIPs on the blacklist would be denied. The first or deny algorithm lets organizations express “check these exceptions first” patterns that cannot be achieved with priority-based algorithms where all permits or all denies are grouped together.

Policy Set Evaluation Result

Evaluating a policy set against an authorization subscription means assigning a decision value based on the target expression and the contained policies:

Target Expression Policy Values Policy Set Value
false (not matching) don’t care NOT_APPLICABLE
true (matching) care Result of the Combining Algorithm applied to the Policies
Error don’t care INDETERMINATE

An error in the target expression always makes the whole set INDETERMINATE, regardless of the combining algorithm and its error handling. The combining algorithm’s error handling governs errors raised inside the policies, not a failure of the set’s own target. This separation is deliberate: the target is evaluated independently of, and ahead of, the policies, which is what allows a policy set to participate in the compile-time policy index. Routing a target error through the combining algorithm instead would couple target and body evaluation and remove that ability.

For how combining algorithms resolve multiple votes into a single decision, see Combining Algorithms.