caddy icon indicating copy to clipboard operation
caddy copied to clipboard

event: Implement event system

Open francislavoie opened this issue 3 years ago • 1 comments

francislavoie avatar Jul 25 '22 19:07 francislavoie

Thanks for this. I'm also inventing an eventing system (say that 10x fast) in parallel, so we'll take ideas from both probably and make something awesome. Great start!

mholt avatar Jul 25 '22 19:07 mholt

This branch is now being continued.

Please see #4984 for additional context and documentation

mholt avatar Aug 25 '22 22:08 mholt

Will probably move the exec event handler plugin out into its own repo for now.

(There is rationale for this decision. No known security issues -- except perhaps an abundance of caution -- rather, just going to wait and see what demand there is for event handler plugins. Most users might end up writing their own anyway!)

mholt avatar Aug 27 '22 18:08 mholt

After chatting in Slack, we've agreed this feature is ready to be merged in its experimental state. It will be iterated upon through time and production experience.

One lingering question is whether users will want to plug in event handler modules that don't need any configuration -- i.e. custom modules that should only subscribe to events. Right now there's not really an API for a module that only subscribes to events. Right now an App module is probably the best fit. But even then it has to appear in the configuration.

I'm not sure how much demand there will be for this, since right now all Caddy modules that are used appear in the configuration. So let's see what the requirements are and the feedback is over time and we can tune this. Because it is experimental we can make breaking changes (though we will try not to).

Thanks @francislavoie for making this possible and laying the groundwork!

mholt avatar Aug 31 '22 20:08 mholt

The next event handler that would be great to have, will be a webhook/call

my use case: opening port 80 incoming (and any other) firewall rule(s) only during the ACME authentication phase. The 3xx/4xx/5xx responses could be an early certification failure event, while the 2xx a continue with the cert_obtaining event.

hevisko avatar Oct 12 '22 17:10 hevisko

@hevisko So basically, make an HTTP request? Sounds logical.

mholt avatar Oct 12 '22 17:10 mholt