cloudflare-php
cloudflare-php copied to clipboard
FirewallRuleOptions is missing the new managed_challenge option
The class Cloudflare\API\Configurations\FirewallRuleOptions used while creating or updating firewall rules is missing the new managed_challenge option.
i have noticed the same issue, i cannot find a way to se the firewall rules to "manage challenge"
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
);