Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API access to firewall rules and aliases #1858

Closed
noahmehl opened this issue Oct 1, 2017 · 17 comments
Closed

API access to firewall rules and aliases #1858

noahmehl opened this issue Oct 1, 2017 · 17 comments
Assignees
Labels
feature Adding new functionality
Milestone

Comments

@noahmehl
Copy link

noahmehl commented Oct 1, 2017

Definition

As a user, I need API access to update firewall aliases and rules. The specific use case is to run an agent on my servers (fail2ban for instance), that can update a firewall alias list with banned IP addresses for the firewall rule/s.

Next Steps

Not sure how to get started on such a thing... Also, please let me know if this is a duplicate of an existing issue.

@AdSchellevis
Copy link
Member

It's on the roadmap, but long time, since we need the legacy code to move into manageable direction, this #1326 for example is a prerequisite and then we should move all validations into a model/controller construction.

A possible short-term win could be to add an api to the aliases and start from there, for most scenarios access to the aliases is enough (like fail2ban), less validations there and less attributes to worry about. Still quite some work, but fits the roadmap.

@noahmehl
Copy link
Author

noahmehl commented Oct 2, 2017

Well, I'm for anything that allows me to update aliases from an API :). Is this something that has to be sponsored? I don't know if I have the skillset to help programmatically...

@AdSchellevis
Copy link
Member

I’m working in that area, but very busy. I’ll put it on my list of things todo, maybe 18.1, I can’t promise

@AdSchellevis AdSchellevis self-assigned this Oct 2, 2017
@AdSchellevis AdSchellevis added the feature Adding new functionality label Oct 2, 2017
@fichtner fichtner added this to the Future milestone Dec 20, 2017
AdSchellevis added a commit that referenced this issue May 29, 2018
…rm fetch code and our standard templates, when specified in the form a data tag separator wil be added, which is used to render the results in getFormData().

In some cases it can be practical if something else then a comma can be used to split fields.

slightly related to #1858.
AdSchellevis added a commit to OPNids/core that referenced this issue May 30, 2018
AdSchellevis added a commit to OPNids/core that referenced this issue May 30, 2018
AdSchellevis added a commit to OPNids/core that referenced this issue May 30, 2018
…rm fetch code and our standard templates, when specified in the form a data tag separator wil be added, which is used to render the results in getFormData().

In some cases it can be practical if something else then a comma can be used to split fields.

slightly related to opnsense/core#1858.
AdSchellevis added a commit that referenced this issue Jun 1, 2018
…entually combine the different validations for the supported alias types.
MaxOrelus pushed a commit to OPNids/core that referenced this issue Jun 1, 2018
…ich should eventually combine the different validations for the supported alias types.
AdSchellevis added a commit that referenced this issue Jun 3, 2018
…egacy code base, needed for #1858

We probably could also use filter_var here, but while shifting to new code it's probably better to align the logic to avoid searching for inconsistencies after migration.
AdSchellevis added a commit that referenced this issue Jun 4, 2018
@fichtner fichtner modified the milestones: Future, 18.7 Jun 4, 2018
fichtner pushed a commit that referenced this issue Jun 11, 2018
(cherry picked from commit a14378c)
AdSchellevis added a commit that referenced this issue Jun 11, 2018
…hange event to support custom hooks, a bit related to #1858
fichtner pushed a commit that referenced this issue Jun 11, 2018
…hange event to support custom hooks, a bit related to #1858

(cherry picked from commit 5ea028d)
AdSchellevis added a commit that referenced this issue Jun 11, 2018
…ter fix functionality first. The old one has quite difficult handling with events, which complicated #1858

this item however was also on the list in #2227
AdSchellevis added a commit that referenced this issue Jun 26, 2018
…a and expects the callback to filter them, which forces us to include the fieldname in the validator to prevent feeding the wrong results. for #1858
AdSchellevis added a commit to OPNids/core that referenced this issue Jul 4, 2018
…egacy code base, needed for opnsense/core#1858

We probably could also use filter_var here, but while shifting to new code it's probably better to align the logic to avoid searching for inconsistencies after migration.
AdSchellevis added a commit to OPNids/core that referenced this issue Jul 4, 2018
AdSchellevis added a commit that referenced this issue Jul 24, 2018
…no description is provided in get_alias_description(). closes #2495
fichtner pushed a commit that referenced this issue Jul 27, 2018
fichtner pushed a commit that referenced this issue Jul 27, 2018
fichtner pushed a commit that referenced this issue Jul 27, 2018
…no description is provided in get_alias_description(). closes #2495

(cherry picked from commit d811c64)
fichtner pushed a commit that referenced this issue Jul 27, 2018
… the migration inactive for the time being.

(cherry picked from commit eeb14c2)
@mimugmail
Copy link
Member

Tested new aliases in current master. Why don't you display "content" in the overview? It's quite unusual when you have a huge list but no IP addresses in overview volt listed.

@mimugmail
Copy link
Member

image

@AdSchellevis
Copy link
Member

@mimugmail content can be quite large (and usually is), but we probably can add the first x items there

@mimugmail
Copy link
Member

Indeed, but as you can see from the screenshot it looks a bit odd compared to legacy code

@AdSchellevis
Copy link
Member

@mimugmail e42c3d2 should do the trick

@mimugmail
Copy link
Member

Looks good, thanks 👍

fichtner pushed a commit that referenced this issue Sep 8, 2018
@fichtner
Copy link
Member

Except for final merge date we are all done here with a bonus MVC rework on top for table diagnostics page. :)

Great work by @AdSchellevis

@mimugmail
Copy link
Member

First upgrades in a couple of systems went smoothly. Very nice work @AdSchellevis ..very appreciated :)

@AdSchellevis
Copy link
Member

@mimugmail thanks!

@fichtner
Copy link
Member

yes, thanks @AdSchellevis ❤️

@michlschmid
Copy link

hey @AdSchellevis is there a documentation of your API?

...I stummbled around in the user / development manual and only came up to this
but it's missing sth. liken an "Firewall Alias" part:

thanks for any hint!

@AdSchellevis
Copy link
Member

@vlabmichl the general concept is found here https://docs.opnsense.org/development/how-tos/api.html best use the inspector in your browser to find the exact payload for an endpoint (all endpoints are used in the alias page and diagnostics -> pfTables).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Adding new functionality
Development

No branches or pull requests

5 participants