Contact: Friendly Captcha v2, opstartvalidatie, ASF-host met Contact-module en hosttests (CMS-U9)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -112,3 +112,34 @@ Rebased onto `origin/master` `e671078` (merge of PR #11: identity-email-notifica
|
||||
- Env var `Contact__RecipientEmail` (SLP: environment only, like ASF). Optional `Contact__Mail__SweepSeconds|MaxAttempts|ClaimMinutes|BatchSize`, `Contact__Mail__BackoffMinutes__0..n`.
|
||||
- Mail itself needs the host's normal `Email:*` configuration; without it messages stay `pending` with `mailError: "disabled"`.
|
||||
- Detail: `nextMailAttemptAt`; resend: `mailError`. New migration `ContactMailClaim`.
|
||||
|
||||
|
||||
## 8. CMS-U9 additions (Friendly Captcha v2 and the ASF host)
|
||||
|
||||
### Captcha contract (no wire change)
|
||||
- `GET /contact-messages/token` -> `captcha: null` while off, otherwise `{ "provider": "friendlycaptcha", "siteKey": "<public site key>" }`. Nothing else about the captcha (API key, verify URL) is ever returned.
|
||||
- `POST /contact-messages`: `captchaToken` = the widget's response string (the widget also puts it in the form field `frc-captcha-response`). While the captcha is on, a **missing, empty or rejected** value is treated as spam: answer `202 {"status":"received"}` identical to a genuine message, stored with status `spam` (never a 400, so a bot learns nothing). While the captcha is off the field is ignored.
|
||||
- Verify (server side, Friendly Captcha **v2**): `POST https://global.frcapi.com/api/v2/captcha/siteverify` (EU-only: `https://eu.frcapi.com/api/v2/captcha/siteverify`), header `X-API-Key: <API key>`, JSON `{ "response": "...", "sitekey": "..." }`; `success:true` passes, `success:false` (HTTP 200 `response_invalid|response_timeout|response_duplicate`, or 400 `response_missing|bad_request`) = spam. Checked against developer.friendlycaptcha.com on 2026-11-10.
|
||||
- **Fail-open**: timeout (default 3 s), network error and 5xx let the visitor through (warning `captcha_unavailable`, kind only). Our own wrong API key or site key (HTTP 401, or 400 with `error_code: sitekey_invalid`) also lets the visitor through but logs an **error** `captcha_misconfigured`. The response token, the API key and the site key are never logged.
|
||||
|
||||
### Configuration (per site)
|
||||
| Key | Notes |
|
||||
|---|---|
|
||||
| `Contact:Captcha:Enabled` | default `false` |
|
||||
| `Contact:Captcha:Provider` | `friendlycaptcha` (only supported value; case-insensitive) |
|
||||
| `Contact:Captcha:SiteKey` | public; sent to the browser |
|
||||
| `Contact__Captcha__Secret` | the API key; **environment variable / secrets manager only**, never committed |
|
||||
| `Contact:Captcha:VerifyUrl` | default global v2 URL; use the EU URL above for EU-only processing; must be https |
|
||||
| `Contact:Captcha:TimeoutSeconds` | default 3 (1-30) |
|
||||
|
||||
With `Contact:Enabled=true` and `Captcha:Enabled=true` the host **refuses to start** when provider, site key or secret is missing/invalid (the message names the setting only, never a value).
|
||||
|
||||
### Widget (website session) and CSP
|
||||
- Widget: Friendly Captcha v2 SDK with `sitekey` = `siteKey` from the token response; for the EU endpoint the widget needs `apiEndpoint: "eu"` (`data-api-endpoint="eu"`). The response goes into `captchaToken`. Exact SDK package/events: to be verified by the website session against the SDK docs.
|
||||
- **CSP**: the v2 widget renders in iframes. The provider's CSP guide says you need `frame-src https://*.frcapi.com` (global and EU). `StrictSite` currently has no `frame-src` (iframes fall back to `default-src 'self'` and are blocked). The additive catalogue change `SecurityHeaders:AllowedSiteFrameOrigins` (StrictSite only, absent = header byte-identical) is **prepared but NOT included in this unit**; waiting for the owner's decision on exact origins vs wildcard and on global vs EU. No `connect-src`/`script-src` additions are documented by the provider.
|
||||
- Privacy (provider statements, v2 docs): "Friendly Captcha does not rely on user tracking or cookies for its protection service"; the dedicated EU endpoint is "hosted in Germany" and "personal information (i.e. visitor IP addresses) never leave the EU". The site's privacy page must name the captcha provider and the processing of the visitor's IP address for the challenge.
|
||||
|
||||
### ASF host (`Api.AndreaSlopFotografie`)
|
||||
- References `Modules.Contact`; section `Contact` in its `appsettings.json` (`Enabled:false`, `SiteId: andreaslop`), the three contact rate-limit policies. Capabilities now list `Contact`; the module does nothing and touches no database while `Contact:Enabled=false`.
|
||||
- Release conditions (also in the comment of that section): `ForwardedHeaders__KnownProxies__0` = reverse proxy (IIS) address first (otherwise the whole site shares one bucket); `Contact__RecipientEmail` (env only); mail via `Email__Smtp__*`, `App__PublicBaseUrl`; sender = `Email:FromAddress` or the address chosen in the site settings from `Email:AllowedFromAddresses` (set by environment for ASF); captcha settings above; then `Contact__Enabled=true` and the admin switch (Berichten).
|
||||
- Host tests (`Api.AndreaSlopFotografie.Tests/ContactHostTests.cs`, real MariaDB): closed by default; public routes stay reachable (200/202) while the availability gate is "not available" and the management routes answer 503; per-client buckets with a known proxy vs one shared bucket without.
|
||||
|
||||
Reference in New Issue
Block a user