nuxt-modules / turnstile

đŸ”Ĩ Cloudflare Turnstile integration for Nuxt
https://cloudflare.com/products/turnstile
MIT License
215 stars 17 forks source link

feat: load secret from storage at runtime #297

Open dargmuesli opened 5 months ago

dargmuesli commented 5 months ago

🆒 Your use case

It's common to have secrets available as a file or similar when deploying a service (as explained in https://github.com/nuxt-modules/turnstile/pull/174#issuecomment-1478161449). I'd like to be able to source the Turnstile secret key from such a file in production.

🆕 The solution you'd like

In https://github.com/nuxt-modules/turnstile/pull/174 we added secret sourcing to the module code, which runs at build time. I now noticed that secret sourcing doesn't work at runtime, at which it makes most sense. It would be beneficial if the secret key could be sourced in the Nitro verify util (instead).

🔍 Alternatives you've considered

Warn for no secret key when building for production: https://github.com/nuxt-modules/turnstile/pull/296

ℹī¸ Additional info

cc @danielroe

Also, should we continue to just use node:fs when a secret key path is given or could we make use of something like unstorage maybe? Don't know if I understand that tool correctly.