Documentation

with

Conditional execution block

with

The with block provides conditional execution of pipelines based on the result of a condition pipeline. It evaluates a condition and executes different pipelines depending on whether the condition succeeds or fails.

Syntax

with [pipeline directive] {
    # Condition pipeline - determines which branch to execute
    condition-actions...
} do {
    # Execute this pipeline if condition succeeds (returns true)
    success-actions...
} else {
    # Execute this pipeline if condition fails (returns false) - optional
    failure-actions...
}

Parameters

  • pipeline directive (optional): Pipeline directive for the condition block. Defaults to while
  • condition pipeline: Actions that determine the outcome
  • do pipeline: Actions executed when condition succeeds
  • else pipeline (optional): Actions executed when condition fails

Example

aaa {
    policy "DEFAULT" {
        handler "AUTHENTICATION" {
            execute {
                # Check if backend authentication succeeds
                with {
                    backend "LDAP_AUTH";
                } do {
                    # Backend authentication successful
                    accept "LDAP authentication successful";
                } else {
                    # Backend authentication failed
                    reject "LDAP authentication failed";
                }
            }
        }
    }
}

This example demonstrates using with to conditionally handle authentication based on a backend check. If the LDAP backend authentication succeeds, the user is accepted. If it fails, the user is rejected with an appropriate message.