Review round 3: job-queue rules keep Payload's own defaults; a failed 2FA lookup fails closed
Job queue (R3-1): only a rule that exists is wrapped. At config time that is what the project wrote; Payload fills in the rest when it builds the config (3.94.1: run, queue and cancel are all defaultAccess, a logged-in user) and the sweep of the running config wraps those. No default is invented, so a request without a user gets what Payload itself answers. hasTotp false while the account's record carries a TOTP secret (the 2FA package's own lookup failed, R3-4): the account owes its code, not 'not set up yet'. Docs: the two-configs-in-one-process case for calls without a source, and that a half-logged-in editor's browser is refused media files. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
c56f0d41b8
commit
dc5326ea1c
@@ -419,6 +419,24 @@ describe('no exception by name: a later plugin\'s `payload-…` collection is gu
|
||||
})
|
||||
})
|
||||
|
||||
describe("the job queue keeps Payload's own defaults", () => {
|
||||
// Payload's `defaultAccess` (3.94.1 fills run, queue and cancel with it when the config is built)
|
||||
const payloadDefault = (user: unknown) => Boolean(user)
|
||||
|
||||
test('without a user: what Payload itself answers; a password-only session is refused; a verified one is not', async () => {
|
||||
const access = payload.config.jobs.access!
|
||||
const admin = (await payload.find({ collection: 'users' as never, where: { email: { equals: '[email protected]' } } })).docs[0]
|
||||
const as = (user: unknown) => ({ req: { payload, user } }) as never
|
||||
for (const op of ['queue', 'cancel', 'run'] as const) {
|
||||
expect([op, await access[op]!(as(null))]).toEqual([op, payloadDefault(null)])
|
||||
expect([op, await access[op]!(as({ ...admin, _strategy: 'local-jwt', collection: 'users' }))]).toEqual([op, false])
|
||||
expect([op, await access[op]!(as({ ...admin, _strategy: 'totp', collection: 'users' }))]).toEqual([op, true])
|
||||
}
|
||||
// the Local API with access control on and no user: refused by Payload's own default, with or without the plugin
|
||||
await expect(payload.jobs.queue({ input: {}, overrideAccess: false, task: 'no-such-task' } as never)).rejects.toThrow(/not allowed/i)
|
||||
})
|
||||
})
|
||||
|
||||
describe('the code cannot be guessed: verify attempts are limited per account', () => {
|
||||
const GUESS_SECRET = 'ONSWG4TFORRW6ZDF'
|
||||
let cookie: string
|
||||
|
||||
Reference in New Issue
Block a user