Cloudflare Turnstile on e-mail sign-up and password reset, and a limit per address
- The sign-up and "forgot password" forms carry a token from Cloudflare Turnstile's widget (managed, shown only when Cloudflare asks for a click); the backend checks it before an e-mail goes out. Off without TURNSTILE_SITE_KEY and TURNSTILE_SECRET_KEY (development); the site key comes to the page through /v1/config. - At most ten such e-mail requests an hour per visitor address, so a script cannot make the site mail thousands of strangers. - The privacy notice (HU, EN) mentions Turnstile with Cloudflare. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -110,6 +110,10 @@ pub struct Config {
|
||||
/// Object storage of the uploaded photos (see [`crate::storage`]); `None`
|
||||
/// when `S3_ENDPOINT` is not set (photo uploads are then refused).
|
||||
pub storage: Option<crate::storage::StorageConfig>,
|
||||
/// `TURNSTILE_SITE_KEY` and `TURNSTILE_SECRET_KEY`: Cloudflare Turnstile
|
||||
/// on the e-mail sign-up and password reset forms (see [`crate::turnstile`]);
|
||||
/// `None` without both (development): no check.
|
||||
pub turnstile: Option<crate::turnstile::TurnstileConfig>,
|
||||
/// `S3_CREATE_BUCKET` (default false): create the bucket at startup if it
|
||||
/// is missing (development; in production it is made in the console).
|
||||
pub storage_create_bucket: bool,
|
||||
@@ -226,6 +230,14 @@ impl Config {
|
||||
Some("open") => SignupMode::Open,
|
||||
Some(other) => bail!("invalid SIGNUP_MODE '{other}': use 'invite' or 'open'"),
|
||||
},
|
||||
turnstile: match (var("TURNSTILE_SITE_KEY"), var("TURNSTILE_SECRET_KEY")) {
|
||||
(Some(site_key), Some(secret)) => Some(crate::turnstile::TurnstileConfig {
|
||||
site_key,
|
||||
secret,
|
||||
verify_url: var("TURNSTILE_VERIFY_URL").unwrap_or_else(|| crate::turnstile::VERIFY_URL.to_string()),
|
||||
}),
|
||||
_ => None,
|
||||
},
|
||||
storage: match var("S3_ENDPOINT") {
|
||||
None => None,
|
||||
Some(endpoint) => Some(crate::storage::StorageConfig {
|
||||
@@ -279,6 +291,7 @@ impl Config {
|
||||
max_charts_per_user: 50,
|
||||
free_person_slots: 5,
|
||||
signup_mode: SignupMode::Open,
|
||||
turnstile: None,
|
||||
storage: Some(crate::storage::StorageConfig {
|
||||
endpoint: format!("{horoscope_api_url}/s3"),
|
||||
bucket: "photos".into(),
|
||||
|
||||
Reference in New Issue
Block a user