Repository navigation
firewall: automation: Explore UI possibilities (POC) #8367
Description
Important notices
Before you add a new report, we ask you kindly to acknowledge the following:
- I have read the contributing guide lines at https://github.com/opnsense/core/blob/master/CONTRIBUTING.md
- I am convinced that my issue is new after having checked both open and closed issues at https://github.com/opnsense/core/issues?q=is%3Aissue
Is your feature request related to a problem? Please describe.
Since the legacy firewall UI pages are at some point, well, um, legacy, there has to be a replacement at some point. The most valid replacement right now is "Firewall: Automation: Filter", which uses the modern mvc framework to generate and display its rules.
The only issue with that, is the User Experience. 10 or 20 firewall rules should not be an issue, but if the view scales up to 100 or 1000 elements even, there could be usability issues.
Describe the solution you like
Brainstorm the possibilites of improving UX in that view to prepare for the future:
Prime directives:
- The consistent sequence of rules in the view at all times
- Do not stray too far from what the framework established
- (There is some hacky stuff in the FilterController to inject the legacy internal rules into searchRuleAction to show them in the bootgrid. Though the actual API output has not been altered, these rules can be added to the output via type in the request.)
General UX:
-
Move the current code to the reusable grid structure to expose all options
-
Ensure firewall rules cannot be sorted (would destroy consistent sequence)
-
Create custom formatters to replicate the old legacy firewall view as first step
-
Custom commands to change the sequence of a rule relative to the other rules, this needs some controller magic
-
Show change message when custom command was used.
-
Analyze the basic needs of a firewall rule, and selectively hide more fields in advanced view or auto collapsed headers inside the main form. For maintainability, having all fields in the same general form is the best.
-
Restrict size of bootgrid dropdown like here:
<style> -
Create AutoNumberField that automatically increases by 10, and not 1. This will help in larger rulesets where you want to set rules between other rules later on. If the sequence is always unbroken, youd need to move a rule up like 500 times or so after creation at the bottom of the ruleset. Increase allowed sequence to 99.999. -
Maybe increment by 100 per default and increase max sequence to 999.999 to leave more space inbetween rules. -
When cloning, the auto number field does not automatically take a new sequence. Add a button that will fill in the next free sequence.
-
Collect all fields that are marked as advanced, and if one of them is not null/empty, display a symbol in in the icons of the rule, and also show in a tooltip which option it is. Additionally trigger the advanced mode automatically.
-
The custom move up and down commands can also work while categories or search is used.
-
Implement a "move rule before other rule" button. Auto calculate the sequence so no micro management of it needs to happen.
-
Show Alias shortcut in grid
-
Show selectpicker with all interface names/ interface groups with possibility or multi selection, request handler to filter the grid based on interface selection. This selectpicker should be in the action bar, at the left side. To populate it, we need an API endpoint that collects all interfaces currently used in rules (also the automatic ones).
-
Change default pagination to e.g. 14 as default, 7 seems too low.
-
Solution for automatic rules visibility, maybe just another grid that uses a search endpoint to list them.
- This one will be a bit trickier, thoughts:
- Write a wrapper and pass them through configd.
- Resolve real interface names in the wrapper script.
- Normalize the legacy data structure to resemble the automation model structure
- Create merged data that combines legacy and automation rules for use with UIModelGrid
- Use this merged data in searchRuleAction(), this fixes pagination issues etc...
- Do not show rowtoggle and command buttons for internal rules
- Show firewall rule search button with #ref for internal rules
-
Solution for diagnostics per rule (hits etc... like the old Inspect button), maybe they can be collected from an endpoint and injected as additional columns via formatter.
-
Categories work, new ones can be added in "/ui/firewall/category".
-
The Interface based filter needs some logic to correctly display the inheritence of rules between
- Legacy Internal/Internal 2
- Legacy Floating
- Legacy Group
- Legacy Interface
- MVC Rules (Which I hope should be calculated solely by their sequence)
Describe alternatives you considered
Rebuilding the current legacy firewall view as closely as possible with no further additions.
Additional context
This is a POC, nothing that is written here or investigated will be a guarantee.
Activity
firewall/filter: Implement grid and apply button partials, change seq…
firewall/filter: Create custom formatters to show inverted source, de…
firewall/filter: Create custom formatter for icons, displaying the sa…
firewall/filter: Create custom command that can swap two firewall rul…
firewall/filter: Finetune custom command to move rules up or down in …
mimugmail commentedon Feb 26, 2025
I'm not sure if it's the correct move, to switch a feature which is intended to act as an api endpoint to a UX / UI rewrite of the old rules. In complex setups you need some kind of scripting and automation like with ansible to add rules. There is no need to have a nice look at those rules on the end system, as they are managed by some other instance like ansible or puppet.
This will break make existing setups.
It would be smarter to rewrite the old ones from scratch of clone the automation base.
AdSchellevis commentedon Feb 26, 2025
@mimugmail Eventually you would like to have only a single view on the rules, but adding an api layer on top of the legacy rules will have a higher regression risk and duplicates the things we already have. Which means its more practical to extend the existing api parts so they can serve the ui (in the same way all other mvc components do)
mimugmail commentedon Feb 26, 2025
@AdSchellevis the main problem is, that rewriting rules and taking automation as the base, make current external implementations and use-cases of automation useless. If I understand correctly, you want to enrich automations with (GUI) features so it can take over service at some point in favor of legacy rules.
But when you already rely on automation rules, where it's totally clear that no human will ever add/remove/edit rules, this will break every logic. To me, the current state is perfect. You have interface rules which everyone can edit (like end customers), then you have automation rules on top of it, so an admin oder MSP can overrule things, but as a last resort end user can still overrule with floating. No automation tool can kill existing rules, no user can break automation.
Imagine a corporate network with 1000 users and above, maybe there is a small network team inside which want to do daily tasks, but still, the network is managed by a MSP, so they can have preference while still IT stuff don't need for tickets to be done. :)
AdSchellevis commentedon Feb 26, 2025
@mimugmail the api part should be backwards compatible, there's already a ui on top of it, but very limited.
It wasn't intended to act as an acl barrier to be honest. In most cases it doesn't make sense to have 2 components performing the same task, the current construct was always intended to replace the existing one (even by the customer paying for it at the time). Deprecating the legacy component will likely take quite some time and might be kept alive for quite time.
mimugmail commentedon Feb 27, 2025
Ok, my concern is that currently the ansible playbooks create rules with sequence numbers via automation.
If you add UI magic to automation and let the users allow to create rules there, and if I saw correctly, you add autoincrement to sequence numbers .. it feels like breaking things.
Maybe I'm wrong ... but from outside, reading the only the topic itself "firewall", "automation" and "explore UI possibilities" is the wrong approach.
AdSchellevis commentedon Feb 27, 2025
It starts with a poc, but the existing api calls and their meaning is certainly a valid concern (and something we're investigating).
The acl boundary is just less of a concern, I do understand people might use the split approach, but that's less a design choice from our end. The intention to use this as our main firewall was always the case (see also the original ticket opnsense/plugins#1720)
Monviech commentedon Feb 28, 2025
The unique constraint has been removed from the sequence field.
firewall/filter: Implement grid and apply button partials, change seq…
firewall/filter: Create custom formatters to show inverted source, de…
firewall/filter: Create custom formatter for icons, displaying the sa…
firewall/filter: Create custom command that can swap two firewall rul…
firewall/filter: Finetune custom command to move rules up or down in …
firewall/filter: Implement grid and apply button partials, change seq…
firewall/filter: Create custom formatters to show inverted source, de…
firewall/filter: Create custom formatter for icons, displaying the sa…
firewall/filter: Create custom command that can swap two firewall rul…
firewall/filter: Finetune custom command to move rules up or down in …
mimugmail commentedon Apr 1, 2025
Had a quick look at master branch, nice work @Monviech :)
Still my little concern, if you, at one day, migrate legacy rules to this rewrite, try to consider user added rules at prio 400000 and make automation rules still prio 200000 in order to not break existing setups :)
AdSchellevis commentedon Apr 1, 2025
@mimugmail it's unlikely we will try to auto-migrate as there are a lot of corner cases which are difficult to predict. A rule export/import might help switch people from one to the other when we're ready to move this to the default. Similar strategy as with some other legacy components.
Monviech commentedon Apr 1, 2025
@mimugmail Thanks for checking it out, I'm happy you like the direction. :)
mimugmail commentedon Apr 1, 2025
@AdSchellevis this means after export/import, every rule is at prio 200000, maybe at some point we can integrate a new api call to stick in between (100000 and 200000) and we'll rewrite the ansible scripts.
@Monviech yep, but you'll still not getting rid of drag&drop lovers ;)