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:
co-authored by
Claude Fable 5.2
parent
8fa71238ce
commit
42fdad8c2d
@@ -141,6 +141,51 @@ export const securityRules: DoctorRule[] = [
|
||||
group: 'security',
|
||||
source: 'static',
|
||||
},
|
||||
{
|
||||
// Without `access` the plugin adds no roles: every account that can log in to the panel is an admin.
|
||||
id: 'access-missing',
|
||||
check: (ctx) => {
|
||||
const code = cfg(ctx)
|
||||
if (!/ipalKit\s*\(/.test(code)) {return []}
|
||||
// `access: { authCollection | defaultRole | … }`, an empty `access: {}`, or a variable whose name says so
|
||||
const set = /\baccess\s*:\s*\{\}/.test(code.replace(/\s+/g, '')) || /\baccess\s*:\s*\{[^{}]*\b(?:authCollection|defaultRole|authAccess|firstUserAdmin|staffCollections|panelRole|selfRegistration|password)\b/.test(code) || /\baccess\s*:\s*\w*[aA]ccess\w*\s*[,}]/.test(code)
|
||||
return set
|
||||
? []
|
||||
: [{ file: configFile(ctx) ?? 'payload.config.ts', fix: "ipalKit({ access: { authCollection: 'users' } }) — roles admin > editor > user; or record the reason in ipal-doctor.json", message: 'ipalKit has no `access` option: there are no roles, so every account that can log in to the panel is an admin', severity: 'warning' }]
|
||||
},
|
||||
docs: 'docs/access.md',
|
||||
group: 'security',
|
||||
source: 'static',
|
||||
},
|
||||
{
|
||||
// Turnstile lets submissions through while it is misconfigured or Cloudflare fails ("degraded") — visible here.
|
||||
id: 'turnstile-degraded',
|
||||
check: (ctx) => {
|
||||
const status = ctx.deep?.turnstile
|
||||
if (!status || status.state !== 'degraded') {return []}
|
||||
const hours = status.since ? Math.floor((Date.parse(`${ctx.today}T23:59:59Z`) - Date.parse(status.since)) / 3_600_000) : null
|
||||
const long = hours !== null && hours >= 24
|
||||
return [{
|
||||
fix: 'Site integrations → Spam protection: both keys from the same Cloudflare widget; then send a test form',
|
||||
message: `Turnstile is not checking forms (${status.code ?? 'unknown'})${status.since ? `, since ${status.since.slice(0, 16).replace('T', ' ')}` : ''}: text forms are accepted without the check and forms with files are refused (unless forms.turnstileOnConfigError says otherwise)`,
|
||||
severity: long ? 'error' : 'warning',
|
||||
}]
|
||||
},
|
||||
docs: 'docs/turnstile.md',
|
||||
group: 'security',
|
||||
source: 'deep',
|
||||
},
|
||||
{
|
||||
// The secret key from the environment is deprecated: the panel is its source.
|
||||
id: 'turnstile-env-key',
|
||||
check: (ctx) =>
|
||||
ctx.deep?.turnstileSecretFromEnv
|
||||
? [{ fix: 'copy the key into Site integrations → Spam protection → Secret key, check a form, then remove TURNSTILE_SECRET_KEY from the environment (Coolify)', message: 'the Turnstile secret key comes from the TURNSTILE_SECRET_KEY environment variable (deprecated; it will be removed in a later release)', severity: 'warning' }]
|
||||
: [],
|
||||
docs: 'docs/turnstile.md',
|
||||
group: 'security',
|
||||
source: 'deep',
|
||||
},
|
||||
{
|
||||
id: 'cookie-scanner',
|
||||
check: (ctx) => {
|
||||
|
||||
Reference in New Issue
Block a user