Repository navigation
feat(auth)!: cut managers over to passwordless, disabling the local strategy - #861
Conversation
…trategy
`loginPlugin` now sets `auth.disableLocalStrategy: { enableFields: true }`
and `maxLoginAttempts: 0` on every collection it serves. Payload then throws
`Forbidden` on the first lines of `login`, `forgotPassword`, `resetPassword`,
`verifyEmail`, `unlock` and `registerFirstUser`, so the cut-over is enforced
by the framework rather than by our own guard. Verified against 3.87.1.
The object form is deliberate, and is not the bare `true` that `Clients`
uses: `getAuthFields` gates `email`, `_verified` and `sessions` on it, and
the invitation and magic-link flows need all three.
The switch lives in the plugin so that removing `loginPlugin()` returns the
collection to passwords in one edit, which is what the ticket asks for.
`maxLoginAttempts: 0` is separate work: Payload defaults it to 5 whether or
not a collection names it, so leaving it unset would keep a `loginAttempts` /
`lockUntil` pair nothing can set and `unlock` can no longer clear. The
migration drops both columns and adds them back on `down`. It does NOT touch
`hash` or `salt` — that is the irreversible step, and it waits on the
break-glass decision.
The smoke lane loses `POST /api/managers/login`, so `loginPlugin` wires
`POST /api/<slug>/exchange-preview-secret` where — and only where —
`shouldSeedPreviewAdminHere()` already provisions the admin. It compares
`PREVIEW_ADMIN_PASSWORD` against the environment, timing-safely, and mints a
session for the seeded address alone. The gate is the wiring, not a branch
inside the handler, so production registers no such route at all. No new CI
secret: the workflow already passes that value.
`seedPreviewAdmin` stops writing a password and stops reconciling a lock that
no longer exists.
Refs #840
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013Bgy331z6gnXpFTmxnYPno
…w credential Both changes come out of the review pass, and both are about blast radius. `passwordless` is a `LoginCollectionConfig` member rather than something the plugin does to everything it serves. Adding a second slug to `collections` — `clients` is the obvious candidate, and it needs the bare `disableLocalStrategy: true` — would otherwise have given it `email`, `_verified` and `sessions` columns and taken its lock away, from a one-line edit to an array. `previewExchange` is a `LoginPluginOptions` member, resolved by `previewSecretExchange()` in the plugin that already owns the gate, the variables and the account. The login plugin no longer imports `serverEnv` or knows what a Railway preview is, and the wiring spec folds the plugin twice with two option values instead of resetting the module registry six times. Also from the pass: `constantTimeEqual` moves to `src/lib/utilities/` now that it has two callers, `sessionCookie` joins `createSession` for the same reason, and the preview-admin address is resolved once by `previewAdminEmail()` instead of copied. `testData.createManager` stops writing a password Payload now drops. The admin login page loses Payload's own form — it renders `LoginForm` only while `disableLocalStrategy` is falsy — so the "Email me a sign-in link" control is the whole login and is now the primary action. Refs #840 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013Bgy331z6gnXpFTmxnYPno
…manager Two gaps the review pass found in the cut-over, both of which would have surfaced only when somebody tried to use the thing. `seeds/run.ts` still POSTed `ADMIN_EMAIL`/`ADMIN_PASSWORD` at `/api/managers/login`, which now answers 403 — so every remote seed run, the flow `seeds/AGENTS.md` documents, would have failed at authentication. It takes `ADMIN_TOKEN` instead: the `payload-token` cookie of an operator's own signed-in session. Local runs are unaffected; auto-login still short-circuits ahead of it. `registerFirstUser` is `Forbidden` under `disableLocalStrategy`, and `admin.autoLogin` needs a row that already exists, so an empty `managers` table had no bootstrap at all. `scripts/create-manager.ts` writes one through the local API, which the closed routes do not gate. Also from the pass: the exchange route compared a lowercased address but queried the raw environment value, so a `PREVIEW_ADMIN_EMAIL` carrying a capital would have refused a correct secret forever; and it now refuses an unaccepted admin rather than answering 200 with a token the JWT strategy will not honour. The stale "let `local-jwt` handle it" line in `localizedRolesAuth` is corrected. Refs #840 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013Bgy331z6gnXpFTmxnYPno
The runbook still listed a Payload admin password among the credentials worth keeping, and the coverage map still named the login route the smoke lane no longer calls. Refs #840 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_013Bgy331z6gnXpFTmxnYPno
|
🚅 Deployed to the SahajCloud-pr-861 environment in sahajcloud
1 service not affected by this PR
|
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The switch is the right shape and the diff is no bigger than #840. Payload enforces the cut-over, passwordless is per-collection because it is a schema change, and both additions earn their place.
One decision is yours, and is not code. Closes #840 closes a ticket whose "no password hash survives" criterion is deliberately unmet, and whose break-glass question AGENTS.md answers while the body says this PR takes no position.
Findings
- should-fix —
Closes #840against two unmet criteria.AGENTS.md:41 - should-fix — the exchange is wired plugin-wide, where
passwordlessis per-entry.loginPlugin.ts:270 - should-fix — a docblock describing the login it replaced.
seeds/run.ts:269 - consider — an
emailin the body the server knows.exchangePreviewSecret.ts:16 - consider — a pasted cookie where
useAPIKeyexists.seeds/env.ts:41
What was checked
Read login/, previewAdmin/, localizedRolesAuth.ts, seeds/run.ts, create-manager.ts, the exchange spec, the migration. #840 walked criterion by criterion. git grep ADMIN_PASSWORD: no live reader left. useAPIKey is only at Clients:252, with no email.
Generated by Claude Code
`passwordless` is per-entry because which auth columns a collection carries is not a plugin-wide decision. The exchange was wired plugin-wide, so adding a second slug to `collections:` would have handed it a route trading the *manager* preview secret for a session on that collection — and `clients`, the obvious candidate, uses the bare `disableLocalStrategy: true` and so carries no top-level `email` for the lookup to match. A 500, not a refusal. The spec's per-collection case was watched fail: wiring it plugin-wide again reddens it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01X7B7yds7o6MbQGJLFhydWg
It described the login this replaced — "authenticate with the API", and a token read off the login response body — while the error message below it tells the operator to copy a cookie. The CSRF paragraph is load-bearing and still true, so it is corrected rather than deleted. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01X7B7yds7o6MbQGJLFhydWg
The route holds the one address it trades, so requiring the caller to echo it gated nothing an attacker holding the secret could not supply — the address is the documented default in `tests/e2e/_helpers/preview.ts` — while adding a way for a capital in `PREVIEW_ADMIN_EMAIL` to refuse a correct secret. Dropping it removes the field, the compare, and that hazard. Unknown keys are stripped, so `ensureAdmin` posting `PREVIEW_ADMIN` whole is unaffected, and the integration spec now pins that an `email` in the body is ignored rather than honoured. Each rewritten assertion was watched fail against the old shape. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01X7B7yds7o6MbQGJLFhydWg
The production row asserted there is no break-glass credential, which is the decision #840 still lists as open — and which the PR body says it takes no position on. It now states what is true (no password opens production) and names the question as open, so the docs and the ticket agree. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01X7B7yds7o6MbQGJLFhydWg
|
Addressed the adversarial review — 4 commits, pushed to e1e0f54. Adopted:
Rebutted:
Asked: the break-glass decision, and whether to file the follow-up. Gate green: lint, both typechecks, 2242 unit, 38 targeted int. Each rewritten assertion was watched fail first. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Ardnived
left a comment
There was a problem hiding this comment.
Why do we have both a /admin/login and /managers/signin page? We should get rid of one path and only use the other. The interface on /admin/login also doesn't look right. The button isn't centered.
Also how can simplify the preview admin setup? Maybe we can use a PREVIEW_ADMIN_EMAIL env var, and whenever that admin is used on the request signin page we are auto logged in. This ENV var would only be set in the preview environment and would also be rejected to be used on production. Then the preview environment needs to be initialized with this admin. Then we can directly login with this email address without receiving any email. Would that work?
`node:crypto.timingSafeEqual` is the platform primitive for this, and the app runs only on a long-lived Node server — `src/instrumentation.ts` states there is no edge runtime, and `src/plugins/login/session.ts` already imports `node:crypto` in the same plugin as the exchange. The hand-rolled loop's stated reason (a Worker runtime with no `node:crypto`) did not hold. The length pre-check stays, because `timingSafeEqual` throws on unequal buffers rather than answering, and it now compares byte length: two strings of equal `String.length` can encode to different byte counts, which the old `charCodeAt` loop tolerated and a naive port would have thrown on. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_017MeuqZHNEXjbKtmcrGLzaE
|
⏳ fire failed (503). I will retry after 14:42Z. 🤖 sydevs dispatcher |
|
⏳ fire failed (503). I will retry after 14:43Z. 🤖 sydevs dispatcher |
|
⏳ fire failed (503). I will retry after 14:44Z. 🤖 sydevs dispatcher |
|
⏳ fire failed (503). I will retry after 14:45Z. 🤖 sydevs dispatcher |
|
Nothing to adopt. The one open ask landed in
No commit, so no push and no gate run. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
The old path never shipped, so no mailed link addresses it and nothing needs forwarding. /admin/login is the only sign-in route. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The page already carries the brand, so the lead alone introduces the form, with "No password needed." on its own line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
#840 left one question open: how a human reaches production /admin when email delivery is down. It gates the hash-nulling migration, and the reviewer asked for it settled in this PR rather than a follow-up. The answer is a script, not a route. `scripts/signin-link.ts` mints the same token the sign-in mail carries and prints the URL. It grants nothing to anyone who does not already hold DATABASE_URL and PAYLOAD_SECRET, so it adds no network surface — unlike the preview exchange endpoint this PR deleted, which was one env-var typo away from being a way in on production. It restates both refusals `issueMagicLink` applies, because it skips that function: a link for an inactive or never-accepted account authenticates nobody one request later, and printing one would read as a working break-glass that is not one. It does not stamp `magicLinkIssuedAt` — the throttle bounds anonymous requests, and stamping here would lock the operator out of the mailed path after a run that went to the wrong address. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_017idHbNZuso6kFHCyn6hjCw
|
Break-glass settled in this PR — b3d62b2 pushed. One half of the ask is blocked.
So the PR still says 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
scripts/signin-link.ts signed a token without stamping magicLinkIssuedAt, and redeemMagicLink spends a link only while its issuedAt equals that stamp, so every link it printed was refused as invalid. The stamp-and-sign step is now mintSignInLink, shared with issueMagicLink, and a spec redeems the link it returns. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes the last #840 criterion, "no password hash survives in the database". - 20260929_173315_null_manager_password_hashes nulls hash, salt and the three reset columns on managers. Irreversible by design: login refuses every password while passwordless is set. Its snapshot also heals the chain, which main's storage_object_key snapshot had left with the login_attempts/lock_until columns this PR drops. - loginPlugin drops a password sent on an update: Payload still hashes one there under disableLocalStrategy { enableFields: true }, which would have put a hash straight back. - The atlas seed and preview-event-emails stop sending one. - docs/environment.md and tests/COVERAGE.md stop describing the deleted preview exchange route. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The hash-nulling migration is in (face7b9), so this PR now says
Checked against #840's acceptance criteria:
Lint, typecheck, the unit lane and the manager integration specs all pass locally. Generated by Claude Code |
The old path shipped in #849, four days before this branch moved sign-in into the admin login view. Production has been mailing `/managers/signin?invite=`, `?token=` and `?link=` URLs since then, so deleting the forward 404s every invitation still inside its 7-day window and every reminder link inside its 10-day one. The manager it was sent to holds no other credential, so there is no way back in for them. This reverts aa4c1dc, which removed the forward on the premise that the old path never shipped. `src/app/(frontend)/managers/signin/page.tsx` is on `main` today. Four comments already said the forward was load-bearing and one of them gave the exact expiry windows; all four were deleted along with it. So the rule moves into a spec that fails when the redirect goes missing or stops being permanent, rather than staying prose a reader has to believe. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01QKn3Da33MtvBuuaLrj8jqo
|
Verified the migration, and found one regression in the same area — 4356646 pushed.
Body corrected: it still claimed the old path never shipped. Lean gate green (2256 unit), plus 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
This reverts 4356646. The old page did ship in #849, but production mailed no sign-in link, invitation or reminder link to it before this branch moved sign-in to /admin/login, so no link addresses it and there is nothing to forward. Decided by the maintainer on the PR. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Payload's Banner, .field-type and Button each bring a margin sized for a
full admin form, and stacked on the column's gap they doubled some spaces
and not others — most visibly once a notice appeared. The view now has a
single gap and no child margins (SignIn.module.css, Button margin={false}),
replacing the inline styles.ts.
Also records on MANAGER_SIGNIN_PATH that /managers/signin is deliberately
not forwarded, so the redirect is not restored a third time.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- index.tsx is the view itself, so the one-line barrel goes. The three
delivered-link branches share confirmOrRefuse, the confirmation form is
inline (it rendered once), and the notice copy moved in beside the one
place that picks it — notices.ts, ConfirmSignIn.tsx, SignInView.tsx and
index.ts are gone.
- SignIn.module.css styles the column's children by element and by
Payload's own classes, so no child needs a className and Button no
longer needs margin={false}.
- actions.ts calls redirect outside the try instead of catching it and
sniffing the NEXT_REDIRECT digest back out.
No behaviour or copy change; the four states render as before.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The gate, the address and the auto sign-in address were three functions in three files answering one question. resolvePreviewAdminEmail(input) is now the pure gate and returns the normalised address or undefined; previewAdminEmail() asks it of the live environment, and both the seeder and loginPlugin read that. The seeder therefore matches on the stored (lowercased) spelling too, where it used the raw variable before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- endpoints.ts holds the request route and the three redeem routes, which were five files of one body plus four thin specs; loginPlugin adds them with loginEndpoints(entry). - links.ts builds all three mailed URLs through one pageUrl, replacing pageLink.ts, invite.ts's inviteUrl/signInviteFor and magicLinks.ts's signInUrl. - LoginCollectionConfig loses generateEmailHTML, generateEmailSubject and redirectTo, which no collection set. The redeem fallback is Payload's routes.admin. - magicLinks.ts's invitesAccounts and redeemToken's inline verify check are one hasAcceptedFlag. - token.ts builds the sign-in and invitation sign/read pairs from one baseKind; session.ts loses a duplicated docblock and a stale mention of the deleted preview exchange. - invite.ts renders the invitation inline, and the barrel stops exporting fifteen names nothing outside the plugin imports. No behaviour change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…wn file The three redeem routes differed only in which reader they called and in a few per-kind rules. The route was never what kept the kinds apart — the token's audience is, and each reader verifies it. So: - readAnyLoginToken reads the kind off the token's audience and verifies with that kind's reader, which re-checks the same audience; a relabelled audience fails the signature, and one naming no login kind is invalid. - POST /api/<slug>/redeem replaces redeem-magic-link, redeem-invite and redeem-link. rulesFor(token) holds what differs by kind: single use, the landing page, the tab preference and the refusal wording. - Every mailed link is the sign-in page's ?token=, and the page picks its copy from the same reader. loginUrls.ts is one redeemUrl. - endpoints/requestMagicLink.ts and endpoints/redeem.ts, one route each. The route-separation specs become kind-separation specs: a sign-in token is spent by sign-in rules and an invitation by invitation rules, whichever route they would once have been posted to. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
login,forgotPassword,resetPassword,verifyEmail,unlockandregisterFirstUseritself, and the admin login page renders only "Email me a sign-in link".PREVIEW_ADMIN_EMAILis the way in. Asking for a sign-in link as that one address mints the session instead of mailing it, so the smoke lane needs no password and no route of its own. Production, CI and local dev never set it.scripts/signin-link.ts. It prints the same token the sign-in mail carries, from a shell that already holdsDATABASE_URLandPAYLOAD_SECRET— so feat(auth): cut managers over to passwordless, disabling the local strategy #840's open question is answered here rather than in a follow-up.hash,saltand reset columns, andloginPlugindrops apasswordsent on an update — the one path Payload still hashes under this option. With that, this PR closes feat(auth): cut managers over to passwordless, disabling the local strategy #840.Changes
src/plugins/login/types.ts—LoginCollectionConfig.passwordlessand.previewAutoSignInsrc/plugins/login/loginPlugin.ts— appliespasswordlessto an entry that asks, never plugin-widesrc/plugins/login/magicLinks.ts— the auto sign-in branch, beside the throttle and the eligibility refusal it sharessrc/plugins/login/endpoints/requestMagicLink.ts— carries the minted session back astokenplus a cookiesrc/plugins/login/endpoints/redeem.ts— onePOST /api/managers/redeemfor all three link kinds, replacingredeem-magic-link,redeem-inviteandredeem-link; the token's own audience picks the rules (readAnyLoginToken), and every mailed link is the sign-in page's?token=src/plugins/login/session.ts—sessionCookieParts, the same cookie in the shape a Server Action can setsrc/components/admin/SignIn/— the sign-in view that replaces Payload's/admin/login; its action signs the preview admin in and redirects to/adminnext.config.mjs—Referrer-Policy: no-referreron/admin/login, whose query carries the credentialsrc/plugins/previewAdmin/previewAutoSignIn.ts— answers which address may do that, or noneseeds/run.ts,scripts/create-manager.ts— the two operator paths that password login used to carryscripts/signin-link.ts— production's break-glass: a sign-in link printed, not mailed. Mints throughmintSignInLink(magicLinks.ts), which stampsmagicLinkIssuedAt— without the stamp the redeem route refused every link it printedsrc/migrations/20260929_173315_null_manager_password_hashes.ts— nulls the hashes; see Migrationseeds/atlas/import.ts,scripts/preview-event-emails.ts— stop sending a passwordsrc/plugins/storage/cloudflareStreamWebhook.ts— the constant-time compare, now local to its one callerPreview
PREVIEW_ADMIN_EMAILhere lands you in/admin_verifiedcolumn, which is the accepted/not-accepted flag nowSecrets
PREVIEW_ADMIN_EMAILreplacesPREVIEW_ADMIN_PASSWORD, and is set in both places the smoke lane needs it — the Railway environments previews fork from, and the repository's CI secrets — with an unguessable local part, since the address is the credential on a preview.PREVIEW_ADMIN_PASSWORDcan be deleted from both once this merges.Email previews
No mail changed.
ResetPasswordEmail.tsxis deleted andsrc/plugins/email/index.tsonly repoints a JSDoc example, so there is nothing to render.Migration
src/migrations/20260928_231710_disable_manager_passwords.ts— dropsmanagers.login_attemptsandmanagers.lock_until. Reversible:downadds both back, nullable, with the same defaults.src/migrations/20260929_173315_null_manager_password_hashes.ts— data only: nullshash,salt,reset_password_token,reset_password_expirationandreset_password_requested_aton every manager. The columns stay, because Payload still declares them under{ enableFields: true }.downis a no-op. A hash cannot be rebuilt, and restoring one would buy nothing, sinceloginrefuses every password whilepasswordlessis set..jsonis a fresh snapshot of the merged tree.main's20260929_043344_storage_object_key.jsonpredates this PR's column drop, somigrate:createre-emitted that drop here; the DDL is removed and the snapshot kept, which heals the chain (feat(regions): country slug = ISO alpha-2 code #566). A probemigrate:createafterwards writes nothing.SELECT count(*) FROM managers WHERE hash IS NOT NULL OR salt IS NOT NULLgoes from 1 to 0 with every row kept.Test results
pnpm lint,pnpm typecheck,pnpm typecheck:tests,pnpm test:unit(2256 passed)preview-auto-signin(unit + int),session-cookie-parts,preview-admin-gate,constant-time-equal,manager-passwordless,manager-magic-link,manager-signin-page,manager-invite,login-plugin,lib-boundary— 72 integration assertions and the unit laneManual verification
PREVIEW_ADMIN_EMAIL: no mail, and the form lands you in/admin.POST /api/managers/loginon the preview with any credentials → 403.pnpm dev, then/adminstill auto-logs in.pnpm tsx scripts/signin-link.ts <a manager's address>prints a link that signs that manager in, and refuses an inactive or never-accepted one.SELECT count(*) FROM managers WHERE hash IS NOT NULL OR salt IS NOT NULLreturns 0.Notes for reviewer
Break-glass is answered, and it is a script. #840's open question — how a human reaches production
/adminwhen email delivery is down — is settled byscripts/signin-link.ts, which mints the same sign-in token the mail carries and prints the URL. It is deliberately not a route: it grants nothing to anyone who does not already holdDATABASE_URLandPAYLOAD_SECRET, whereas the preview exchange endpoint this PR deleted was one env-var typo away from being a way in on production.AGENTS.mdanddocs/environment.mdname it where they used to name the question.No password hash survives, and none can come back.
null_manager_password_hashesclears them, and it answers #840's second open question: no reversal path and no dump, because the hashes are unusable whileloginis closed. Nulling alone would not have held — Payload'supdatestill hashes apasswordunder{ enableFields: true }(collections/operations/utilities/update.js), and self-access lets any manager send one for their own row, sologinPluginnow drops it before the operation reads it.manager-passwordless.int.spec.tswatched that fail first.The break-glass script did not work until this PR's last commit. It signed a token without stamping
magicLinkIssuedAt, and the redeem route spends a link only while the two match, so every link it printed would have been refused as invalid.mintSignInLinknow stamps and signs for both it andissueMagicLink, andmanager-magic-link.int.spec.tsredeems its link.One #840 criterion was superseded in review, not met as written. "The smoke lane authenticates against a preview with no new CI secret" assumed the preview exchange route. The review replaced that route with
PREVIEW_ADMIN_EMAIL(thread), which renames the one secret rather than adding a second:PREVIEW_ADMIN_PASSWORDgoes when this merges.The preview credential is the address, and that was accepted deliberately (thread). Anyone who opens a preview and types
PREVIEW_ADMIN_EMAILbecomes its admin, and preview hosts are enumerable — so the local part must not be guessable, and there is no default any more: an environment without the variable provisions no admin and signs nobody in. In exchange, a preview-only endpoint, a second credential and a CI secret all disappear.The sign-in page is
/admin/login(thread). Payload's login view is replaced throughadmin.components.views.login./managers/signinis gone, with no forward. It shipped in #849, but production mailed no sign-in link, invitation or reminder link to it before this branch moved sign-in to/admin/login, so no link addresses it (maintainer's call, 2026-09-30).MANAGER_SIGNIN_PATH's docblock records that, so the forward is not restored a third time.Two gaps the review pass found, both fixed here, both worth knowing about because they are the shape of what else might break: the seed runner authenticated with
ADMIN_EMAIL/ADMIN_PASSWORDand now takesADMIN_TOKEN, and an emptymanagerstable had no bootstrap at all, whichscripts/create-manager.tsrestores.Detail
The object form, not the bare
trueClientsuses.getAuthFields.jsgatesemail, the verification columns, the lock columns andsessionson!disableLocalStrategy || …enableFields, so baretruewould drop all four — and the invitation flow needsemailto address the link,_verifiedas its accepted flag, andsessionsforcreateSessionto mint into. Verified against[email protected].maxLoginAttempts: 0is separate work from the switch. Payload defaults it to 5 whether or not a collection names it (collections/config/defaults.js:140), so removing the line fromManagers.tsleft the columns in place. Setting it to zero is what drops them.Two operations read the option differently, and both change behaviour.
refresh.js:42tests!disableLocalStrategy, so the session branch is skipped — a refresh no longer extends the session row or prunes expired ones.logout.js:27tests!== true, so its session-clearing branch still runs, which is what keeps a logout final. Both are pinned bymanager-passwordless.int.spec.ts; the refresh one is asserted rather than described because the row is what a latercreateSessionprunes against.local-jwtdisappears. Payload pushes it only for a collection whosedisableLocalStrategyis falsy (payload/dist/index.js:434,441), and both auth collections now set it. Managers keep working becauseaccessPlugin'slocalized-rolesstrategy wrapsJWTAuthenticationitself; clients keep working because the API-key strategy is registered fromuseAPIKeyon a separate branch. The spec asserts both, andlocalizedRolesAuth.ts's docblock — which explained a fall-through that no longer exists — is corrected rather than deleted.admin.autoLoginsurvives untouched, because it lives inside the JWT strategy (strategies/jwt.js) rather than in theloginoperation.The auto sign-in is a branch in
issueMagicLink, not a route. That is where the account lookup, the eligibility refusal and the uniform answer already live, and the shape it replaced — a preview-only endpoint — was one env-var typo away from being a way in on production. There is no route to get wrong now:tests/unit/preview-auto-signin.spec.tsasserts the served paths are identical with the option set and unset.It sits above the throttle, and refuses an unaccepted account. Above, because the smoke lane signs in many times per run and a minute's wait between them would fail it while bounding nothing — nothing is mailed and no link is minted on that path. Refusing an unaccepted account, because the JWT strategy yields no user while
_verifiedis false, so minting there would answer 200 with a token that authenticates nobody, one request later.The break-glass script restates both of those refusals, because it skips
issueMagicLinkentirely. A link printed for an inactive or never-accepted manager would read as a working way in and authenticate nobody one request later. It also does not stampmagicLinkIssuedAt: the throttle exists to bound what an anonymous request can generate, and stamping here would lock the operator out of the mailed path for a minute after a run that went to the wrong address.passwordlessstays per collection. The plugin serves any auth collection, and the object form applied plugin-wide would rewrite the auth columns of the next slug added tocollections—clientsneeds the baredisableLocalStrategy: trueand would gainemail,_verifiedandsessionsfrom a one-line edit to an array.previewAutoSignInneeds no such guard: it is a value on one entry, whichpayload.config.tsspreads ontomanagersalone.Why the composition root resolves the address.
loginPluginserves any auth collection; knowing what a Railway PR preview is belongs topreviewAdmin, which owns the gate, the variable and the account.src/payload.config.tsis the one place that legitimately knows both.previewAutoSignInEmail()also lower-cases and trims, because Payload'semailfield normalises on every write and a capital in the variable would otherwise match no row.The gate is unchanged apart from what it reads. It still requires a Railway environment name, still refuses production, and now requires
PREVIEW_ADMIN_EMAILwhere it required the password. Reading the environment name rather thanNODE_ENVremains load-bearing: a preview runsNODE_ENV=production, and CI genuinely holds the secret, so a gate reading only the variable would provision an admin into the integration lane's database.preview-admin-gate.spec.tsdrives every combination.The page half needed
sessionCookieParts. A Server Action cannot send aSet-Cookieheader, so it sets the cookie throughcookies().setand redirects. The parts are parsed fromgeneratePayloadCookie's own output rather than rebuilt — a second derivation of the name, the expiry orsecurewould drift from what the redeem routes send, and a session cookie wrong by one attribute fails only in a browser.session-cookie-parts.spec.tspins the two against each other, and earned itself twice: Payload spells the flagsHttpOnly=true, and a copied value would read aSecure=falseas secure.redirectthrows, so the action cannot swallow it. Next signals a navigation with aNEXT_REDIRECTdigest, and thecatcharoundissueMagicLinkexists to swallow transport failures — catching the redirect too would leave the preview admin on the page, signed in, reading "check your email".Fixture pre-mortem.
preview-auto-signin.int.spec.tsassumes the plugin resolves the address when the config is built, not per request — checked againstsrc/payload.config.tsandtests/utils/testHelpers.ts, which is why the environment is set invi.hoistedrather thanbeforeAll. Otherwise the option would silently be unset and every "no token" case would still pass. Every assertion inmanager-passwordless.int.spec.tswas watched fail: reverting to the baretrueform reddens four, and droppingmaxLoginAttempts: 0reddens the fifth.What was removed, and where its coverage went.
tests/unit/manager-auth-urls.spec.tsonly covered the reset URL.role-based-access'sLogin-lockout reset (unlock)suite has no state left to drive — there is no counter andunlockis refused — and the derivation it defended (#748) is asserted bytests/unit/access-derived-grants.spec.ts, which needs no lockable account. A ⚠ tombstone in each file says so.constantTimeEqualisnode:crypto, and now local to the webhook. The first version compared char codes, justified by a Worker runtime with nonode:crypto;src/instrumentation.tssays the app runs only on a long-lived Node server. It moved tosrc/lib/utilities/while the exchange shared it, and moved intocloudflareStreamWebhook.tswhen the exchange went — one consumer is not shared code, andlib-boundary.spec.tsenforces that. The byte-length pre-check moved with it rather than being inlined away:timingSafeEqualthrows on unequal buffers, so a multi-byte character in a signature would be a 500 instead of a rejected webhook.constant-time-equal.spec.tswas watched fail against aString.lengthcheck.Also from the review pass, and unrelated to the feature:
sessionCookiejoinedcreateSessioninsession.tsonce both had two callers, andseeds/run.ts'sauthenticatedocblock still described the login it replaced, down to a token read off the login response body; the CSRF paragraph it carries is load-bearing, so it is corrected rather than deleted.Closes #840
🤖 Generated with Claude Code
https://claude.ai/code/session_017idHbNZuso6kFHCyn6hjCw