server default {
    listen {
        type = auth
        ipaddr = *
        port = 1812
    }

    authorize {
        preprocess
        
        # Добавляем домен если его нет
        if (!&User-Name =~ /@/) {
            update request {
                User-Name := "%{User-Name}@vz.loc"
            }
        }

        # Устанавливаем тип аутентификации PAM
        update control {
            Auth-Type := PAM
        }
        
        files
    }

    authenticate {
        Auth-Type PAM {
            pam
        }
    }

    post-auth {
        # Получаем группы AD и возвращаем в Class атрибут (25)
        get_ad_groups
        
        update reply {
            &Reply-Message := "2FA Authentication successful"
            &Session-Timeout := 28800
        }
        
        # Логируем успешную аутентификацию
        detail
        
        ok
    }
}
