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: Update DNS Provider list and improve maintainability #4556

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<id>caddy.general.TlsDnsProvider</id>
<label>DNS Provider</label>
<type>dropdown</type>
<help><![CDATA[Select the DNS Provider for the DNS-01 Challenge and Dynamic DNS. Providers marked as "optional" must be installed manually, see https://caddyserver.com/docs/command-line#caddy-add-package. For more information, visit https://github.com/caddy-dns where each module is community maintained.]]></help>
<help><![CDATA[Select the DNS Provider for the DNS-01 Challenge and Dynamic DNS. Providers marked as "optional" must be installed manually, see https://caddyserver.com/docs/command-line#caddy-add-package. Important: When the version of the caddy binary changes, "optional" provider must be reinstalled. For more information, visit https://github.com/caddy-dns where each module is community maintained.]]></help>
</field>
<field>
<type>header</type>
Expand All @@ -118,37 +118,193 @@
<id>caddy.general.TlsDnsApiKey</id>
<label>API Field 1</label>
<type>text</type>
<help><![CDATA[This is the standard field for the API Key. Field can be left empty if optional: Cloudflare "api_token", Duckdns "api_token", DigitalOcean "auth_token", Godaddy "api_token", Gandi "bearer_token", IONOS "api_token", deSEC "token", Route53 "access_key_id", Porkbun "api_key", ACME-DNS "username", Netlify "personal_access_token", Njalla "api_token", Google Cloud DNS "gcp_project", Azure "tenant_id", OVH "endpoint", Namecheap "api_key", PowerDNS "server_url", DDNSS "api_token", Linode "api_token", Tencent Cloud "secret_id", Dinahosting "username", Hexonet "username", Mail-in-a-Box "api_url", DNS Made Easy "api_key", Bunny "access_key", Civo "api_token", Scaleway "secret_key", ACME Proxy "username", INWX "username", Netcup "customer_number", RFC2136 "key_name", Name.com "token", EasyDNS "api_token", Infomaniak "api_token", DirectAdmin "host", Hosttech "api_token", Vultr "api_token", Hetzner "api_token", ClouDNS "auth_id".]]></help>
<help>
<![CDATA[
This is the standard field for the API Key. Field can be left empty if optional for the chosen provider.
Cloudflare "api_token",
Duckdns "api_token",
DigitalOcean "auth_token",
Godaddy "api_token",
Gandi "bearer_token",
IONOS "api_token",
deSEC "token",
Route53 "access_key_id",
Porkbun "api_key",
ACME-DNS "username",
Netlify "personal_access_token",
Njalla "api_token",
Google Cloud DNS "gcp_project",
Azure "tenant_id",
OVH "endpoint",
Namecheap "api_key",
PowerDNS "server_url",
DDNSS "api_token",
Linode "api_token",
Tencent Cloud "secret_id",
Dinahosting "username",
Hexonet "username",
Mail-in-a-Box "api_url",
DNS Made Easy "api_key",
Bunny "access_key",
Civo "api_token",
Scaleway "secret_key",
ACME Proxy "username",
INWX "username",
Netcup "customer_number",
RFC2136 "key_name",
Name.com "token",
EasyDNS "api_token",
Infomaniak "api_token",
DirectAdmin "host",
Hosttech "api_token",
Vultr "api_token",
Hetzner "api_token",
ClouDNS "auth_id",
Gcore "api_token",
Huawei Cloud "access_key_id",
DNSExit "api_token",
Nanelo "api_token",
Katapult "api_token",
Regfish "api_key",
Leaseweb "api_token",
DreamHost "api_key",
Exoscale "api_key",
TransIP "account_name",
Selectel "user",
LuaDNS "email",
Hurricane Electric "api_key",
Namesilo "api_token",
Dode "api_token",
Dynu "api_token",
Glesys "project",
NFSN "login",
GoDaddy "api_token",
Vercel "api_token",
Loopia "username",
DNSPod "api_token",
Mythic Beasts "key_id",
Dynv6 "api_token",
AliDNS "access_key_id",
Metaname "api_key",
]]>
</help>
</field>
<field>
<id>caddy.general.TlsDnsSecretApiKey</id>
<label>API Field 2</label>
<type>text</type>
<help><![CDATA[Leave empty if your DNS Provider isn't specified here. Field can be left empty if optional: Duckdns "override_domain", Route53 "secret_access_key", Porkbun "api_secret_key", ACME-DNS "password", Azure "client_id", OVH "application_key", Namecheap "user", PowerDNS "api_token", DDNSS "username", Linode "api_url", Tencent Cloud "secret_key", Dinahosting "password", Hexonet "password", Mail-in-a-Box "email_address", DNS Made Easy "secret_key", Scaleway "organization_id", ACME Proxy "password", INWX "password", Netcup "api_key", RFC2136 "key_alg", Name.com "server", EasyDNS "api_key", DirectAdmin "user", ClouDNS "auth_password".]]></help>
<help>
<![CDATA[
Leave empty if your DNS Provider isn't specified here. Field can be left empty if optional for the chosen provider.
Duckdns "override_domain",
Route53 "secret_access_key",
Porkbun "api_secret_key",
ACME-DNS "password",
Azure "client_id",
OVH "application_key",
Namecheap "user",
PowerDNS "api_token",
DDNSS "username",
Linode "api_url",
Tencent Cloud "secret_key",
Dinahosting "password",
Hexonet "password",
Mail-in-a-Box "email_address",
DNS Made Easy "secret_key",
Scaleway "organization_id",
ACME Proxy "password",
INWX "password",
Netcup "api_key",
RFC2136 "key_alg",
Name.com "server",
EasyDNS "api_key",
DirectAdmin "user",
ClouDNS "auth_password",
Huawei Cloud "secret_access_key",
Exoscale "api_secret",
TransIP "private_key_path",
Selectel "password",
LuaDNS "api_key",
Dynu "own_domain",
Glesys "api_key",
NFSN "api_key",
Loopia "password",
Mythic Beasts "secret",
AliDNS "access_key_secret",
Metaname "account_reference",
]]>
</help>
</field>
<field>
<id>caddy.general.TlsDnsOptionalField1</id>
<label>API Field 3</label>
<type>text</type>
<help><![CDATA[Leave empty if your DNS Provider isn't specified here. Field can be left empty if optional: Route53 "hosted_zone_id", ACME-DNS "subdomain", Azure "client_secret", OVH "application_secret", Namecheap "api_endpoint", DDNSS "password", Linode "api_version", Mail-in-a-Box "password", DNS Made Easy "api_endpoint", ACME Proxy "endpoint", INWX "shared_secret", Netcup "api_password", Name.com "user", EasyDNS "api_url", DirectAdmin "login_key", RFC2136 "key", ClouDNS "sub_auth_id".]]></help>
<help>
<![CDATA[
Leave empty if your DNS Provider isn't specified here. Field can be left empty if optional for the chosen provider.
Route53 "hosted_zone_id",
ACME-DNS "subdomain",
Azure "client_secret",
OVH "application_secret",
Namecheap "api_endpoint",
DDNSS "password",
Linode "api_version",
Mail-in-a-Box "password",
DNS Made Easy "api_endpoint",
ACME Proxy "endpoint",
INWX "shared_secret",
Netcup "api_password",
Name.com "user",
EasyDNS "api_url",
DirectAdmin "login_key",
RFC2136 "key",
ClouDNS "sub_auth_id",
Selectel "account_id",
]]>
</help>
</field>
<field>
<id>caddy.general.TlsDnsOptionalField2</id>
<label>API Field 4</label>
<type>text</type>
<help><![CDATA[Leave empty if your DNS Provider isn't specified here. Field can be left empty if optional: Route53 "profile", ACME-DNS "server_url", Azure "subscription_id", OVH "consumer_key", Namecheap "client_ip", DDNS "password", INWX "endpoint_url", DirectAdmin "insecure_requests", RFC2136 "server".]]></help>
<help>
<![CDATA[
Leave empty if your DNS Provider isn't specified here. Field can be left empty if optional for the chosen provider.
Route53 "profile",
ACME-DNS "server_url",
Azure "subscription_id",
OVH "consumer_key",
Namecheap "client_ip",
DDNS "password",
INWX "endpoint_url",
DirectAdmin "insecure_requests",
RFC2136 "server",
Selectel "project_name",
]]>
</help>
</field>
<field>
<id>caddy.general.TlsDnsOptionalField3</id>
<label>API Field 5</label>
<type>text</type>
<help><![CDATA[Leave empty if your DNS Provider isn't specified here. Field can be left empty if optional: Route53 "region", Azure "resource_group_name".]]></help>
<help>
<![CDATA[
Leave empty if your DNS Provider isn't specified here. Field can be left empty if optional for the chosen provider.
Route53 "region",
Azure "resource_group_name",
]]>
</help>
</field>
<field>
<id>caddy.general.TlsDnsOptionalField4</id>
<label>API Field 6</label>
<type>text</type>
<help><![CDATA[Leave empty if your DNS Provider isn't specified here. Field can be left empty if optional: Route53 "session_token".]]></help>
<help>
<![CDATA[
Leave empty if your DNS Provider isn't specified here. Field can be left empty if optional for the chosen provider.
Route53 "session_token",
]]>
</help>
</field>
<field>
<type>header</type>
Expand Down
27 changes: 27 additions & 0 deletions www/caddy/src/opnsense/mvc/app/models/OPNsense/Caddy/Caddy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,33 @@
<easydns>EasyDNS (optional)</easydns>
<hosttech>Hosttech (optional)</hosttech>
<cloudns>ClouDNS (optional)</cloudns>
<gcore>Gcore (optional)</gcore>
<huaweicloud>Huawei Cloud (optional)</huaweicloud>
<dnsexit>DNSExit (optional)</dnsexit>
<nanelo>Nanelo (optional)</nanelo>
<katapult>Katapult (optional)</katapult>
<regfish>Regfish (optional)</regfish>
<leaseweb>Leaseweb (optional)</leaseweb>
<dreamhost>DreamHost (optional)</dreamhost>
<exoscale>Exoscale (optional)</exoscale>
<transip>TransIP (optional)</transip>
<selectel>Selectel (optional)</selectel>
<dnsimple>DNSimple (optional)</dnsimple>
<luadns>LuaDNS (optional)</luadns>
<he>Hurricane Electric (optional)</he>
<namesilo>Namesilo (optional)</namesilo>
<dode>Dode (optional)</dode>
<dynu>Dynu (optional)</dynu>
<glesys>Glesys (optional)</glesys>
<nfsn>NFSN (optional)</nfsn>
<godaddy>GoDaddy (optional)</godaddy>
<vercel>Vercel (optional)</vercel>
<loopia>Loopia (optional)</loopia>
<dnspod>DNSPod (optional)</dnspod>
<mythicbeasts>Mythic Beasts (optional)</mythicbeasts>
<dynv6>Dynv6 (optional)</dynv6>
<alidns>AliDNS (optional)</alidns>
<metaname>Metaname (optional)</metaname>
</OptionValues>
</TlsDnsProvider>
<TlsDnsApiKey type="TextField"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,16 @@
{% endfor %}
{% endfor %}

{#
# Define special DNS Providers that have more than one API key, or special requirements that do not allow the use of the default.
# The same providers have to be added to "OPNsense/Caddy/includeDnsProvider", best in the same order as in this array for maintainability.
# For a new provider to work, it has to be compiled into the caddy binary.
#}
{% set dnsProviderSpecialConfig = ['duckdns', 'porkbun', 'desec', 'route53', 'acmedns', 'googleclouddns', 'azure', 'ovh', 'namecheap', 'powerdns', 'ddnss', 'linode', 'tencentcloud', 'dinahosting', 'hexonet', 'mailinabox', 'netcup', 'rfc2136', 'dnsmadeeasy', 'civo', 'scaleway', 'acmeproxy', 'inwx', 'namedotcom', 'easydns', 'directadmin', 'cloudns'] %}
{% import "OPNsense/Caddy/includeDnsProvider" as dns_includes %}
{% set dnsProviderSpecialConfig = dns_includes.dnsProviderSpecialConfig() %}

{# Conditionally add the dynamic_dns section, acmedns provider is special, it does not support dynamic_dns. #}
{% if dnsProvider and dynDnsDomains|length > 0 and dnsProvider != "acmedns" %}
dynamic_dns {
{# duckdns provider is special, it has a different configuration for dynamic dns than for the dns-01 challenge. #}
{% if dnsProvider in dnsProviderSpecialConfig and dnsProvider != "duckdns" %}
provider {{ dnsProvider }} {
{% set context_var = 'dnsProviderSpecialLogic' %}
{% include "OPNsense/Caddy/includeDnsProvider" %}
}
{% else %}
Expand Down Expand Up @@ -332,6 +329,7 @@ http://{{ domain }} {
tls {% if customCert %}/var/db/caddy/data/caddy/certificates/temp/{{ customCert }}.pem /var/db/caddy/data/caddy/certificates/temp/{{ customCert }}.key{% endif %} {% if not customCert and dnsChallenge == "1" and dnsProvider %}{
issuer acme {
dns {{ dnsProvider }} {% if dnsProvider not in dnsProviderSpecialConfig %}{{ dnsApiKey }}{% else %}{
{% set context_var = 'dnsProviderSpecialLogic' %}
{% include "OPNsense/Caddy/includeDnsProvider" %}
}
{% endif %}
Expand Down
Loading