Merge claude/security-c-1172: form submissions over REST only for staff, the job queue for an admin or Bearer CRON_SECRET, doctor visitor-writes

Conflicts with security-a-1172 kept both sides: imports (adminSameOrigin, jobsAccess), the doctor status (originKnown and visitorWrites), its test, and the e2e:built line (A's sign-in answers spec with C's CRON_SECRET).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 11:17:51 +01:00
co-authored by Claude Opus 5.5
40 changed files with 657 additions and 187 deletions
+7
View File
@@ -51,6 +51,7 @@ import { buildLocalizationConfig, validateI18nConfig } from './modules/i18n/inde
import { serverText } from './modules/integrations/texts.js'
import { buildSystemPagesFields } from './modules/pages/index.js'
import { guardAdminEndpoints } from './modules/security/adminSameOrigin.js'
import { jobsRunNotice, withJobsRunAccess } from './modules/security/jobsAccess.js'
import { missingImportMapEntries } from './modules/security/totp/importMapCheck.js'
import { changedViewKeys, copyViews, SAFE_TOTP_VIEW, wrapTotpViews } from './modules/security/totp/safeBack.js'
import { reportRefusedOrigin, requestFromOwnOrigin } from './modules/security/totp/sameOrigin.js'
@@ -987,6 +988,9 @@ export const iapl = (options: IaplOptions): Plugin => {
},
}
// --- Payload's job queue over HTTP: an admin or the cron secret, unless the project wrote its own rule
config = withJobsRunAccess(config, options.jobsRunAccess ?? {})
// --- second factor on everything in the config by now: the project's
// collections (wrapped by the package already; twice is harmless), the
// plugin's globals and collections, the form builder's.
@@ -1016,6 +1020,9 @@ export const iapl = (options: IaplOptions): Plugin => {
watchTransactions(payload, options.connectionReserve === false ? false : (options.connectionReserve ?? defaultConnectionReserve(poolSize(payload) ?? 10)))
// Microsoft Graph is deprecated (removed in 2.0): one warning per start while its variables are set.
if (graphAvailable() && options.mail?.graphDeprecationWarning !== false) {payload.logger.warn(GRAPH_DEPRECATION_NOTICE)}
// The queue is on and the run route is iapl's: say how a cron reaches it, when the secret is missing.
const jobsNotice = jobsRunNotice(payload.config as never)
if (jobsNotice) {payload.logger.warn(jobsNotice)}
// Payload's dev reload swaps `payload.config` and runs no onInit: adopt the new config at once.
watchPayloadConfig(payload, adoptConfig)
if (staleSignInLook) {