M1 (6): nobody creates an account for themselves

accounts.adminOnlyCreate (on): a staff collection without a create rule gets
"an admin, fully signed in" instead of Payload's "any logged-in user" — also the
project's own collection; a rule the project wrote stays.
accounts.firstUserRoute ('panel'): Payload's first-user route answers only for
the collection the panel logs in with. For any other empty auth collection it is
refused, unless that collection's own create rule lets an anonymous request in.
Checked and closed: an empty second staff collection, whose first visitor became
a staff admin (test/accountRulesOff.test.ts records the old behaviour, which
accounts: false / firstUserRoute: 'all' still give).
Doctor: open-signup (deep, info) names auth collections with open sign-up.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 00:39:12 +01:00
co-authored by Claude Fable 5.2
parent cd60b73685
commit c6fc0d21fe
10 changed files with 364 additions and 5 deletions
+9 -1
View File
@@ -181,6 +181,14 @@ describe('M1 rules: access-missing, turnstile-degraded, turnstile-env-key', () =
expect(await run(cfg, ['turnstile-env-key'])).toEqual([])
})
test('open-signup: an auth collection anyone can register in is said, as info', async () => {
const cfg = "ipalKit({ access: { authCollection: 'users' } })"
expect(await run(cfg, ['open-signup'], { openSignUp: ['customers', 'members'] })).toEqual(['open-signup:info', 'open-signup:info'])
expect(await run(cfg, ['open-signup'], { openSignUp: [] })).toEqual([])
expect(await run(cfg, ['open-signup'], { openSignUp: null })).toEqual([])
expect(await run(cfg, ['open-signup'])).toEqual([])
})
test('the deep status reports the state and where the secret comes from, never a key', async () => {
vi.stubEnv('TURNSTILE_SECRET_KEY', 'env-secret-value')
const fake = (integrations: object) => ({
@@ -481,7 +489,7 @@ describe('security and deep status', () => {
}
const status = await collectDoctorStatus(payload as never)
expect(status).toMatchObject({ pendingCookies: 4, usersWithout2fa: 2 })
expect(Object.keys(status).sort()).toEqual(['node', 'pendingCookies', 'plugin', 'turnstile', 'turnstileSecretFromEnv', 'usersSetupClosed', 'usersWithout2fa'])
expect(Object.keys(status).sort()).toEqual(['node', 'openSignUp', 'pendingCookies', 'plugin', 'turnstile', 'turnstileSecretFromEnv', 'usersSetupClosed', 'usersWithout2fa'])
expect(status.usersSetupClosed).toBeNull() // no setup window in this config
})
test('collectDoctorStatus counts the accounts whose 2FA setup window has passed', async () => {