-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Allow jinja2 code in webhook payload_url #8295
Comments
I've had a quick look in the code and you could probably extend the Webhook model with a method
and then reference it in the method netbox/netbox/extras/webhooks_worker.py Line 31 in f94c1e9
If the FR is ok and accepted I can provide a PR for consideration. |
Just as illustration for the use case, I take it you want to do something like this?
Makes sense to me. My only concern is the potential for conflict with existing URLs if we enable Jinja2 rendering (for example, if someone has a URL defined that is evaluated as invalid Jinja2 code), although I'd expect such instances to be very rare. |
Yes, that's pretty much exactly my use case
I thought about the same thing, but couldn't really wrap my head around how a URL like that would look. |
I've learned never to underestimate the bizarre ways in which some enterprise application will abuse URL query parameters. 😆 But maybe it would be sufficient to gate this change in a milestone release (e.g. v3.2 or v3.3). |
This could potentially be gated via a config option, to lower potential risks, and make this opt-int; although I believe the risk is low in any case. |
I agree it would make sense to add this potential breaking change to a milestone release. If it breaks an URL it should just be some small adjustments to make it work with jinja2. |
@rodvand assigning this to you since you volunteered earlier. Just be sure to work off of the |
Fixes: #8295 Render the payload_url of a Webhook with Jinja2
NetBox version
v3.1.5
Feature type
New functionality
Proposed functionality
Allow the use of jinja2 code in the webhook payload_url.
Use case
I have a custom field where I store the ID of an object in my NMS. This allows me to utilise NetBox to control my monitoring (pause monitoring if the device is set to offline as an example). The current setup requires some middleware where I POST to a generic URL and this web server again make a call to the REST API of the monitoring system using the ID in the custom field from the payload data. If I could reference the obj.cf_nms_id directly in the payload_url it would allow me to skip this middleware.
The payload_url would have to be generated on each webhook event.
Database changes
None
External dependencies
No response
The text was updated successfully, but these errors were encountered: