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

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

Merged
merged 24 commits into from
Jul 3, 2024

Conversation

Monviech
Copy link
Member

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"
  • that uses only existing API endpoints of Caddy to show a list of domains+port and their enabled status.
  • The list in the widget is sorted by enabled status. Links are embedded to quickly get to the Caddy configuration pages.
  • When Caddy is disabled, a warning will be shown with a link to the page where Caddy can be enabled.
  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.

@Monviech Monviech marked this pull request as draft June 20, 2024 07:05
@swhite2 swhite2 self-assigned this Jun 20, 2024
Monviech added 3 commits June 21, 2024 07:02
…ip turns yellow when 14 days are left. The remaining days are shown in the overview next to the date.
@Monviech Monviech marked this pull request as ready for review June 23, 2024 08:15
Copy link
Member

@swhite2 swhite2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I like the usage of asyncio here, since openssl doesn't support parsing multiple paths concurrently.. Perhaps @AdSchellevis might have an opinion on this as well.

@Monviech Monviech changed the title www/caddy: [WIP] Add Caddy widgets for 24.7 new dashboard www/caddy: Add Caddy widgets for 24.7 new dashboard Jun 28, 2024
@swhite2 swhite2 merged commit 8ac117f into opnsense:master Jul 3, 2024
@Monviech Monviech deleted the caddy-widget branch July 6, 2024 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants