caddy-dns / cloudflare

Caddy module: dns.providers.cloudflare
Apache License 2.0
475 stars 60 forks source link

Should validate the token input #84

Open francislavoie opened 1 month ago

francislavoie commented 1 month ago

It's unfortunately quite common for users to misconfigure the plugin, either by having some invalid bits of syntax or empty environment variables, etc. We should probably have a regexp to validate the token.

For example, sometimes people read {env.CLOUDFLARE_API_TOKEN} and think "oh I just put my token within the {} because they don't understand what placeholders are, so it doesn't work because the extra {} is invalid. Sometimes people forget to set their env vars properly, so the token is an empty string, or has quotes around it because they set their env value incorrectly.

I don't actually use this myself so I don't know what the token values can look like, but I assume it should be trivial to use a regexp to validate.

mholt commented 1 month ago

Huh. Okay yeah, I guess this is a good idea.