When creating port aliases in OPNsense via the Web GUI, it is possible to use service/port names like "HTTP", "HTTPS", or "HTTP_8080" (aliases), which content are port numbers (e.g., 80, 443, 8080). These service/port names are displayed in the Web GUI as the alias names and the portnumbers as their content.
However, if you try to configure an alias "HTTP_all" via the OPNsense API or via automation tools such as Ansible, which contains the mentioned aliases/port names as content, the specification of service/port names (e.g. 'HTTP') leads to a validation error: "Value 'HTTP' is invalid for the type 'port'!" or ""alias.content":"Entry \"Array\" is not a valid port number.". The API only accepts numeric port numbers and does not allow aliases/port names, which leads to an inconsistency between the web GUI and the API.
This works on the Web GUI without any error message.
Example Input and Output:
Web GUI:
Input: name: "HTTP_all", type: "port", content: ["HTTP", "HTTPS", "HTTP_8080"]
Output: Displays aliases: content: ["HTTP", "HTTPS", "HTTP_8080"], which defined for following ports 80, 443, and 8080 respectively.
API / Ansible:
Input: name: "HTTP_all", type: "port", content: ["HTTP", "HTTPS", "HTTP_8080"]
Output: Error: "Value 'HTTP' is invalid for type 'port'!"
Why is the use of service/port names such as "HTTP", 'HTTPS' or "HTTP_8080" supported as content in port aliases via the Web GUI, but not via the API? Is there a technical limitation that causes this discrepancy? Are there reasons why this can be created via the Web GUI and not via the API?
However, if you try to configure an alias "HTTP_all" via the OPNsense API or via automation tools such as Ansible, which contains the mentioned aliases/port names as content, the specification of service/port names (e.g. 'HTTP') leads to a validation error: "Value 'HTTP' is invalid for the type 'port'!" or ""alias.content":"Entry \"Array\" is not a valid port number.". The API only accepts numeric port numbers and does not allow aliases/port names, which leads to an inconsistency between the web GUI and the API.
This works on the Web GUI without any error message.
Example Input and Output:
Web GUI:
Input: name: "HTTP_all", type: "port", content: ["HTTP", "HTTPS", "HTTP_8080"]
Output: Displays aliases: content: ["HTTP", "HTTPS", "HTTP_8080"], which defined for following ports 80, 443, and 8080 respectively.
API / Ansible:
Input: name: "HTTP_all", type: "port", content: ["HTTP", "HTTPS", "HTTP_8080"]
Output: Error: "Value 'HTTP' is invalid for type 'port'!"
Why is the use of service/port names such as "HTTP", 'HTTPS' or "HTTP_8080" supported as content in port aliases via the Web GUI, but not via the API? Is there a technical limitation that causes this discrepancy? Are there reasons why this can be created via the Web GUI and not via the API?