Radiator Server Documentation — v10.34.2
if
Conditional execution
Table of Contents
if
The if clause allows conditional execution of blocks within authentication,
authorization, and accounting pipelines. It evaluates a specified condition and
executes the enclosed blocks only if the condition is met.
Syntax
if <all | any | none> {
<condition rules>
} then {
# Actions when the first condition block matches
} else if <all | any | none> {
<condition rules>
} then {
# Actions when the second condition block matches
} else {
# Actions when no condition block matches
}
The else if and else clauses are optional. Add as many else if clauses as
needed. Radiator runs the actions of the first clause whose condition block
matches.
Each condition block uses the all, any, or none matching strategy and can
contain comparisons and nested condition blocks. For the matching strategies,
nesting, evaluation order, and comparison operators, see
Condition Blocks.
For example, the following if action accepts mikem in the admin group
and alice in the root group:
if any {
all {
aaa.identity == "mikem";
user.group == "admin";
}
all {
aaa.identity == "alice";
user.group == "root";
}
} then {
accept;
}
Example
aaa {
policy "MANAGEMENT" {
conditions all {
aaa.protocol == protocol.MANAGEMENT;
}
handler "AUTHENTICATION" {
@authentication {
http_management_authentication {
@resolve {
# Add write privilege for users found from the internal file backend
if all {
user.backend == "USERS_INTERNAL_FILE";
} then {
user.privilege = "write";
}
}
@verify {
http_basic_auth;
}
}
}
}
}
}
Related pages
- Conditions and Comparison Operators - for condition blocks and comparison operators.
- Execution Context - for namespace attributes.
- Data Types