Merge local main (1.17.2) into security-a-118

Conflicts resolved by keeping both sides: lockedAnswer + sign-in rules in plugin.ts and switches.ts, IPv6 grouping in the
mail service's new per-visitor address count, both built-site specs in e2e:built, docs and skills (reference copies
synced). The lockedAnswer suite and the sign-in-answers spec now reach Payload's lock the 1.18.0 way: a spray from
50 IPs, one failure each (one IP alone gets 429 after five).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 12:57:52 +01:00
co-authored by Claude Opus 5.5
113 changed files with 3468 additions and 317 deletions
+22 -2
View File
@@ -12,7 +12,8 @@ import { buildNotifications } from './globals/Notifications/index.js'
import { applyGlobalOverrides } from './globals/overrides.js'
import { buildSiteIntegrations } from './globals/SiteIntegrations/index.js'
import { buildSiteSettings } from './globals/SiteSettings/index.js'
import { adminOnly, adminOrSelfIn, injectRoles, registerStaffCollections, staffCollectionSlugs } from './modules/access/index.js'
import { adminOnly, adminOrSelfIn, injectRoles, registerStaffCollections, staffCollectionSlugs, withVersionReadRules } from './modules/access/index.js'
import { withLockedAnswer } from './modules/access/lockedAnswer.js'
import { applyPanelRole, countBelowPanelRole, resolvePanelRole } from './modules/access/panelRole.js'
import { applyPasswordRule, buildPasswordRuleHook, resolvePasswordRule } from './modules/access/passwordRule.js'
import { adoptLateAuthCollections, applyFirstUserRoute, applyStaffAccountAccess, markSeenAuthCollections, markStaffRules, staffCollectionsNobodyManages, unknownStaffCollections } from './modules/access/selfRegistration.js'
@@ -50,6 +51,8 @@ import { withFillLocales } from './modules/hooks/fillEmptyLocales.js'
import { buildLocalizationConfig, validateI18nConfig } from './modules/i18n/index.js'
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'
@@ -130,6 +133,8 @@ export const iapl = (options: IaplOptions): Plugin => {
async function transform(incomingConfig: Config): Promise<Config> {
let config = { ...incomingConfig }
/** The project's own endpoints: the panel-action origin rule (adminSameOrigin) is for the plugin's only. */
const projectEndpoints = new Set<unknown>(incomingConfig.endpoints ?? [])
// Text written in one language fills the empty languages of the same field (cookie list, cookie review).
const fillDefaults = { 'cookie-review': ['purpose', 'retention'], 'cookie-settings': ['cookies.purpose', 'cookies.duration'] }
@@ -265,6 +270,8 @@ export const iapl = (options: IaplOptions): Plugin => {
collections: (config.collections ?? []).map((c) => (staffSlugs.includes(c.slug) ? applySignInRules(c, accounts) : c)),
hooks: { ...config.hooks, afterError: [...(config.hooks?.afterError ?? []), settleFailedSignIn as never] },
}
// A locked staff account answers like a wrong password (accounts.lockedAnswer).
if (accounts.lockedAnswer !== 'payload') {config = withLockedAnswer(config)}
}
if (options.twoFactor !== false) {
const tf = options.twoFactor
@@ -773,7 +780,7 @@ export const iapl = (options: IaplOptions): Plugin => {
reenterSecretOnChange: options.secrets?.reenterOnChange !== false,
writeOnlySecrets: options.secrets?.writeOnly !== false,
}),
withFillLocales('global', buildCookieSettings(), fillLocales['cookie-settings']),
withFillLocales('global', buildCookieSettings(options.cookieSettings), fillLocales['cookie-settings']),
buildNotifications({ lightbox: options.lightbox === true }),
]
// A global feeds every page's layout — revalidate the site on save.
@@ -988,6 +995,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.
@@ -1017,6 +1027,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) {
@@ -1100,11 +1113,18 @@ export const iapl = (options: IaplOptions): Plugin => {
payload.logger.info('[iapl] Plugin initialized.')
}
// readVersions: readPublished() asks for `version._status` on version history (readPublishedVersions).
config.collections = withVersionReadRules(config.collections)
config.globals = withVersionReadRules(config.globals)
// Every auth collection of this config has been seen: what appears later is a late one (adoptConfig).
if (accounts) {
const panel = config.admin?.user ?? (config.collections ?? []).find((c) => c.auth)?.slug
config = markSeenAuthCollections(config, staffCollectionSlugs({ admin: { user: panel }, custom: config.custom }))
}
// The plugin's panel actions (mail service connect / disconnect, test e-mail, cookie scan / approval / crawl)
// only from the site's own origin (adminSameOrigin).
config = guardAdminEndpoints(config, projectEndpoints, options.adminSameOrigin)
return config
}
}