M1 (2, 3): the Turnstile env secret is deprecated; doctor rules access-missing, turnstile-degraded, turnstile-env-key

(2) Stage one of the deprecation: TURNSTILE_SECRET_KEY from the environment still
works when the panel field is empty, logs once that it is deprecated, and the
doctor's deep status reports it (rule turnstile-env-key, warning). Nothing is
removed.
(3) access-missing (static, warning): ipalKit without `access` means every panel
account is an admin. turnstile-degraded (deep): Turnstile is not checking forms —
warning, error after a day. The deep status carries the recorded state and where
the secret comes from, never a key.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 00:39:12 +01:00
co-authored by Claude Fable 5.2
parent 8fa71238ce
commit 42fdad8c2d
8 changed files with 214 additions and 16 deletions
+18 -1
View File
@@ -10,6 +10,7 @@ import { COOKIE_REVIEW_SLUG } from '../consent/scanner/collection.js'
import { secondFactorPassed, SETUP_FROM_FIELD } from '../security/totp/secondFactor.js'
import { countAccountsWithoutTotp } from '../security/totp/setupRequired.js'
import { clientIp, consumeRateLimit, tooManyRequests } from '../shared/rateLimit.js'
import { turnstileSecretFromEnv } from '../turnstile/config.js'
/** The plugin's own version (package.json next to dist/ and src/). */
export function pluginVersion(): string {
@@ -44,7 +45,23 @@ export async function collectDoctorStatus(payload: BasePayload): Promise<DoctorS
}
}
const pendingCookies = collections.some((c) => c.slug === COOKIE_REVIEW_SLUG) ? await countPendingCookies(payload) : null
return { node: process.version, pendingCookies, plugin: pluginVersion(), usersSetupClosed, usersWithout2fa }
// Turnstile: the recorded state and where the secret comes from — never the keys themselves.
let turnstile: DoctorStatus['turnstile'] = null
let secretFromEnv: boolean | null = null
if ((payload.config.globals ?? []).some((g) => g.slug === 'site-integrations')) {
try {
const integrations = (await payload.findGlobal({ slug: 'site-integrations' as never, depth: 0, overrideAccess: true })) as unknown as {
turnstileSecretKey?: null | string
turnstileStatus?: { code?: null | string; since?: null | string; state?: null | string } | null
}
const status = integrations.turnstileStatus
turnstile = status?.state ? { code: status.code ?? null, since: status.since ?? null, state: status.state } : null
secretFromEnv = turnstileSecretFromEnv(integrations)
} catch {
/* the global cannot be read: unknown */
}
}
return { node: process.version, pendingCookies, plugin: pluginVersion(), turnstile, turnstileSecretFromEnv: secretFromEnv, usersSetupClosed, usersWithout2fa }
}
export type DoctorEndpointOptions = {