cloudflare-php icon indicating copy to clipboard operation
cloudflare-php copied to clipboard

FirewallRuleOptions is missing the new managed_challenge option

Open Kovah opened this issue 3 years ago • 2 comments

The class Cloudflare\API\Configurations\FirewallRuleOptions used while creating or updating firewall rules is missing the new managed_challenge option.

Kovah avatar Dec 20 '22 09:12 Kovah

i have noticed the same issue, i cannot find a way to se the firewall rules to "manage challenge"

garethjax avatar Jan 26 '23 14:01 garethjax

I fixed this by extending the class and manually adding the option:

<?php

namespace App\Helper\Cloudflare;

class FirewallRuleOptions extends \Cloudflare\API\Configurations\FirewallRuleOptions
{
    public function setActionManagedChallenge(): void
    {
        $this->configs['action'] = 'managed_challenge';
    }
}

use it like that:

use App\Helper\Cloudflare\FirewallRuleOptions;

$firewallRuleOptions = (new FirewallRuleOptions());
$firewallRuleOptions->setActionManagedChallenge();

$firewall->updateFirewallRule(
    'your_zone_id',
    'your_rule_id',
    'your_filter_id',
    'new_filter_expression',
    $firewallRuleOptions
);

Kovah avatar Jan 26 '23 15:01 Kovah