opnsense / plugins

OPNsense plugin collection
https://opnsense.org/
BSD 2-Clause "Simplified" License
810 stars 593 forks source link

www/caddy: Add Caddy widgets for 24.7 new dashboard #4049

Open Monviech opened 1 week ago

Monviech commented 1 week ago

This PR is for discussion with @swhite2

Coming from the perspective of plugins, the widgets could be pluggable like this. What's left to solve is the translations, so this is like a proof of concept and has to be adjusted.

Screenshot (some domain details have been omitted with text editing):

CaddyWidgetsRedacted

What this adds:

  1. A small widget called "CaddyDomain.js"
  1. A more complicated widget "CaddyCertificate.js" using a /new/ API endpoint that has not existed before.
    • The new API endpoint uses openssl to read all certificates of Caddy from the filesystem. It uses "asyncio" for performance and a fast script execution time, even with many certificates
    • The new "ttl_cache" is used in the actions to cache the result of the script to prevent repeated executions.
    • The API endpoint is consumed by the CaddyCertificate widget, showing the validity status, hostname and localized datetime when it will expire in a neat list.
    • Everything is async and fast.

Since this is a WIP and POC it still needs some cleanup that will be done over time.