Staff sign-in rules: failures per IP and address, own origin, current password for own changes (1.18.0)
Q2 (IAWL idea 16): Payload locks a staff account after 5 wrong passwords from anybody, so a stranger kept the owner out without a password. Failed sign-ins are now counted per client IP and typed address (folded: NFKC, lower case, trim): 5 in 15 min, then 429 for that IP and address only; only failures count (a place taken before the compare, given back on success or refusal; "try again in a moment" while others are being checked). Payload's own lock stays as the net at 50 failures for an hour where the project set none. The mail service's account-mail limit now counts per address per visitor (5) with 20 per address in all, so one stranger no longer blocks the owner's own reset mail. Q3 (idea 7): staff login, forgot and reset password refuse a request a browser marks as coming from another origin (403 before anything is counted or sent); visitor collections untouched. Q5 (idea 29): an account that changes its own e-mail, username or password must send its current password (panel field on the account page via the plugin's MaskedField, no import-map change; REST and GraphQL). Admins changing others, server code and API keys are not asked; wrong ones count like failed sign-ins. Options accounts.signInLimit / signInSameOrigin / confirmOwnChanges, all validated at start. Tests: 15 HTTP tests (2FA on/off, all off), fail before on 1.17.1; built-site spec own-account.spec.ts in e2e:built. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
fc70a34f3e
commit
52710021ef
@@ -1397,3 +1397,23 @@ describe('the adapter on its own, and the deprecated Graph line', () => {
|
||||
expect(quiet.logger.warn.mock.calls.map((c) => String(c[0])).filter((m) => m.includes('deprecated'))).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('account mail per address is counted per visitor too (1.18.0)', () => {
|
||||
test('a stranger who uses up an address from one IP does not stop the owner\'s own reset mail; all visitors together stop at perAddressTotal', async () => {
|
||||
const { fake, options, payload } = relaySite({ fake: { allow: [HOST], limits: { messagesPerHour: 100 } } })
|
||||
const send = (visitor: string, subject: string) => {
|
||||
expectMailTo('[email protected]', 'account', { visitor })
|
||||
// as Payload's "forgot password" goes: marked as account mail for this address, with the requesting visitor
|
||||
return sendThroughRelay(payload, options, { html: 'reset', subject, to: '[email protected]' })
|
||||
}
|
||||
for (let i = 0; i < 5; i++) {expect((await send('203.0.113.9', `Reset ${i}`)).sent).toBe(true)}
|
||||
expect(await send('203.0.113.9', 'Reset 5')).toMatchObject({ cause: 'client-account-mail-limit', sent: false })
|
||||
// the owner, from another address
|
||||
expect(await send('198.51.100.20', 'Reset owner')).toMatchObject({ sent: true })
|
||||
// many visitors together: perAddressTotal (20) for the address
|
||||
let sent = 6
|
||||
for (let i = 1; sent < 20; i++) {if ((await send(`192.0.2.${i}`, `Reset v${i}`)).sent) {sent++}}
|
||||
expect(await send('192.0.2.200', 'Reset over')).toMatchObject({ cause: 'client-account-mail-limit', sent: false })
|
||||
expect(fake.outbox.filter((m) => m.kind === 'account')).toHaveLength(20)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user