opnsense + zenarmor restful api

Started by mhen79, September 26, 2024, 02:39:25 AM

Previous topic - Next topic
Hi,

i got install, configure and run successfully the zenarmor plugin in opnsense.

Now i want to control a working policy via api request, simply to switch on or off the policy.

To get status and some information for all policies is simple done with:
curl -sk -u "$key":"$secret" https://<ip>/api/zenarmor/policy

response:
{
  "policies": [
    {
      "id": 1727212787,
      "local_id": 1727212787,
      "cloud_policyid": "",
      "name": "Allow_Services",
      "isCentralized": false,
      "isActive": true,
      "isDefault": false,
      "user": "0",
      "nodes": [
        {
          "id": "0"
        }
      ],
      "tags": [],
      "projects": [],
      "checksum": 1727212787
    },
    {
      "id": 0,
      "local_id": 0,
      "cloud_policyid": "",
      "name": "Default",
      "isCentralized": false,
      "isActive": true,
      "isDefault": true,
      "user": "0",
      "nodes": [
        {
          "id": "0"
        }
      ],
      "tags": [],
      "projects": [],
      "checksum": 0
    }
  ]
}


My question is, how could i modify the "isActive" status to false, of id:1727212787 ? I could'nt find any documentation regarding toggle on/off policies via api call.

Br,

Marco


Hi,

thank you for the hint to the documentation reference of zenarmor. There is all the stuff very good described, but unfortunately not useable for the zenarmor plugin of opnsense.

I have tried to find a way to enable the zenarmor api of this plugin, but in the settings is no link/button to configure the api module. Maybe you have an idea if or where i could enable the zenarmor api in the opnsense zenarmor plugin.

Have a look to attachment for a short view of the settings tree of the plugin:


Br,

Marco

The Zenarmor Cloud agent must be installed. Also, you cannot perform these operations with a Free license.

September 27, 2024, 07:56:24 PM #4 Last Edit: September 27, 2024, 08:06:19 PM by mhen79
Hi,

for Restful API feature business subscription is needed, more then $100/mon. For private use to much.

Are you sure there is no possibility to control the policies via opnsense api ? I was able to create a new policy via:

curl -sk -X POST -u "$key":"$secret" https://<ip>/api/zenarmor/policy \
-H "Content-Type: application/json" \
-d '{
    "isActive": "false",
    "policy_id": "1727212787"
}'

But, could also be just a bug.

Also the endpoint "https://<ip>/api/zenarmor/policy/set" reacts, but says "{"status":403,"message":"Forbidden"}". Maybe there is a hidden, non documented feature ?

Br,

Marco