M1 review: account rules before 2FA, the SMTP password stays with its server, the rest of the findings

M1-1 the first-user route is the plugin's own endpoint in front of Payload's; nothing is read from the path.
M1-2 the account rules are put on the collections before the 2FA package wraps them.
M1-6 the admin rule only where the roles are the plugin's; other staff collections: an account of that collection.
     update / delete get the matching defaults (accounts.adminOnlyWrite); doctor rule staff-accounts-open.
M1-5 access.firstUserAdmin: false with a role below the panel role: the default panel role steps aside, an explicit one is refused.
M1-3 a save that changes the SMTP server, port, user or encryption must send the password again (secrets.reenterOnChange);
     new panel field smtpRequireTls.
M1-4 a restore of a version masks the secrets (maskSecretsOnRestore).
M1-7 a refused origin is logged once with the ways to allow it; default ports are normalised.
Minors: m1 day boundary, m3 e-mail check on reset and bulk update, m4 text of 'all', m5 the mask is never kept.
The account suite runs with 2FA off and on.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 00:39:23 +01:00
co-authored by Claude Fable 5.2
parent 81cee02e78
commit 1141c749de
28 changed files with 1557 additions and 457 deletions
+17 -2
View File
@@ -24,7 +24,17 @@ export {
export { applyPanelRole, countBelowPanelRole, DEFAULT_PANEL_ROLE, panelAccess, resolvePanelRole } from './modules/access/panelRole.js'
export { applyPasswordRule, buildPasswordRuleHook, checkPassword, DEFAULT_PASSWORD_MIN_LENGTH, resolvePasswordRule } from './modules/access/passwordRule.js'
export type { PasswordRuleOptions } from './modules/access/passwordRule.js'
export { applyAdminOnlyCreate, applyFirstUserRoute, buildFirstUserGuard, openSignUpCollections, staffCreateAccess } from './modules/access/selfRegistration.js'
export {
applyFirstUserRoute,
applyStaffAccountAccess,
buildFirstUserEndpoint,
hasPluginRoles,
openSignUpCollections,
sameStaffCollectionAccess,
staffCollectionsOpenToOthers,
staffCreateAccess,
staffUpdateAccess,
} from './modules/access/selfRegistration.js'
export type { FirstUserRouteOption } from './modules/access/selfRegistration.js'
export type { AccountsOptions } from './modules/access/types.js'
// Concrete files, not module barrels: a barrel that also re-exports 'use client'
@@ -304,15 +314,20 @@ export type { ExtractHeadingsOptions, HeadingItem, HeadingLevel } from './module
// Lexical → Markdown (pure, no React) — for AI-readable output.
export { lexicalToMarkdown } from './modules/richtext/lexicalToMarkdown.js'
export {
buildKeepSecret,
INTEGRATION_SECRET_FIELDS,
isSecretMask,
keepSecretBeforeValidate,
maskSecretAfterRead,
maskSecretsOnRestore,
maskWriteOnlySecrets,
SECRET_CLEAR,
SECRET_MASK,
SMTP_PASSWORD_BOUND_TO,
writeOnlySecret,
writeOnlySecrets,
} from './modules/secrets/writeOnly.js'
export type { WriteOnlySecretOptions } from './modules/secrets/writeOnly.js'
export {
buildAdminCsp,
buildAdminCspHeaders,
@@ -348,7 +363,7 @@ export type { BuildSecurityHeadersArgs, SecurityHeader } from './modules/securit
export { findImportMapFile, missingImportMapEntries } from './modules/security/totp/importMapCheck.js'
export { changedViewKeys, copyViews, SAFE_TOTP_VIEW, safeAdminBack, totpViewImportKey, wrapTotpViews } from './modules/security/totp/safeBack.js'
export type { SafeBackContext, SafeBackRule, TotpViewComponent } from './modules/security/totp/safeBack.js'
export { ownOrigins, requestFromOwnOrigin } from './modules/security/totp/sameOrigin.js'
export { ownOrigins, reportRefusedOrigin, requestFromOwnOrigin } from './modules/security/totp/sameOrigin.js'
export { requireSecondFactor, secondFactorPassed, twoFactorSetupDeadline, twoFactorSetupState } from './modules/security/totp/secondFactor.js'
export type { TwoFactorSetupState } from './modules/security/totp/secondFactor.js'
export { SETUP_FROM_FIELD } from './modules/security/totp/secondFactor.js'