M1 review: docs, agent guide, skills and changelog follow the fixes

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 1141c749de
commit fd203de326
17 changed files with 349 additions and 116 deletions
+53 -15
View File
@@ -23,7 +23,7 @@ ipalKit({
|---|---|---|
| `access.authCollection` | — (required) | the auth collection that gets the `roles` field |
| `access.defaultRole` | `'user'` | role of a new account when an admin did not set one |
| `access.firstUserAdmin` | `true` | the account from the "Create first user" screen (`…/first-register` on an empty collection) gets `['admin']`, even when the form picked `user`; `false` = it gets what was submitted |
| `access.firstUserAdmin` | `true` | the account from the "Create first user" screen (`…/first-register` on an empty collection) gets `['admin']`, even when the form picked `user`; `false` = it gets what was submitted — then mind the panel role, [Account rules](#account-rules-accounts) |
| `access.authAccess` | see the table below | `access` of the **injected** auth collection, merged over the default (your keys win) |
| `access.staffCollections` | `[]` | more auth collections whose accounts count as **staff**, besides the one the panel logs in with (`admin.user`); see "Who is staff" |
| `globalOverrides` | — | changes to the plugin's globals: an object merges `access` / `admin` key by key (your keys win) and appends `hooks` (yours run after the plugin's), other keys (label, fields, …) replace; a function `(global) => global` takes over the whole global |
@@ -234,6 +234,7 @@ ipalKit({
access: { authCollection: 'users' },
// accounts: { panelRole: 'user' }, // every account may open the panel (as before)
// accounts: { adminOnlyCreate: false }, // Payload's default `create` on your own staff collection
// accounts: { adminOnlyWrite: false }, // Payload's default `update` / `delete` there
// accounts: { firstUserRoute: 'all' }, // Payload's first-user route for every empty auth collection
// accounts: { firstUserRoute: ['users', 'partners'] },
// accounts: { password: { minLength: 16 } }, // or password: false
@@ -259,35 +260,69 @@ at the second factor, so the 2FA screens stay reachable.
- **Check:** log in to `/admin` as an account with the role `user` → "Unauthorized"; `GET /api/access` for it →
`canAccessAdmin: false`; `GET /api/users/me` still answers.
### Nobody creates an account for themselves (`accounts.adminOnlyCreate`, `accounts.firstUserRoute`)
### Nobody creates an account for themselves, or takes one over (`accounts.adminOnlyCreate`, `accounts.adminOnlyWrite`, `accounts.firstUserRoute`)
By default only the first account of a site can be registered by a visitor, and it becomes admin
(`access.firstUserAdmin`); every other account is made by an admin.
(`access.firstUserAdmin`); every other account is made by an admin, and an account is changed by an admin or by
its owner.
Payload's default for a collection without access rules is "any logged-in user" for `create`, `update` and
`delete` — an account of **any** auth collection. On a project's own staff collection a visitor account
(`customers`) could therefore create a staff account, or `PATCH` a staff account's password and roles.
| | Before | Now (default) |
|---|---|---|
| Anonymous `POST /api/users`, GraphQL `createUser` | refused | refused |
| The first account: `POST /api/users/first-register` on an empty collection | 200, role `admin` | the same |
| A signed-in editor or plain user creates an account in the plugin's injected collection | refused | refused |
| …in **the project's own** staff collection that has no `create` rule | **allowed** (Payload's default: any logged-in user) | refused — an admin, fully signed in (`staffCreateAccess`) |
| …in **the project's own** staff collection that has no `create` rule | **allowed** (Payload's default) | refused — an admin, fully signed in |
| A visitor account (`customers`) changes or deletes an account of the project's own staff collection that has no `update` / `delete` rule | **allowed** (Payload's default) | refused |
| `POST /api/<slug>/first-register` on another empty auth collection (`members`) | **200** | 403 |
| …on an empty **second staff collection** (`access.staffCollections`) | **200, and that account was staff** | 403 — an admin of the panel's collection creates its first account |
| A collection that allows sign-up (`customers` with `create: () => true`) | allowed | allowed, its first-user route too |
- `adminOnlyCreate` applies to the staff collections (the panel's login collection, `access.authCollection`,
`access.staffCollections`) that have **no** `create` rule; a rule you wrote stays. `false` = Payload's default.
**Which rule a staff collection gets** (the panel's login collection, `access.authCollection`,
`access.staffCollections`) — only for an operation it has **no** rule for; a rule you wrote always stays:
| The collection | `create` | `update` | `delete` |
|---|---|---|---|
| carries **the plugin's roles**: it is `access.authCollection`, or has a `roles` select whose values are all `user` / `editor` / `admin` (`hasPluginRoles`) | an admin (`staffCreateAccess`) | an admin, or the account itself (`staffUpdateAccess(slug)`) | an admin |
| has **roles of its own** (`superadmin`, `writer`, …) or no `roles` field — the plugin cannot tell who its admins are | an account of that same collection, or a plugin admin of another staff collection (`sameStaffCollectionAccess(slug)`) | the same | the same |
Always "fully signed in": a session that still owes its second factor passes none of them. In the second row
your own roles are not enforced by the plugin — what was allowed inside the collection stays allowed; what
closes is the door for accounts of **other** collections. Write your own rules to say who inside may do what.
- `adminOnlyCreate: false` = Payload's default `create`; `adminOnlyWrite: false` = Payload's default `update`
and `delete`. The rules are put on the collections **before** the 2FA package wraps them, so they hold with
2FA on and off.
- `read` is not touched: a staff collection of your own without a `read` rule is readable by any logged-in
account (Payload's default; the injected collection has "admin or self"). Write a `read` rule
(`adminOrSelfIn(slug)`).
- `firstUserRoute`: `'panel'` (default) = the collection the panel logs in with; a list of slugs = those;
`'all'` = Payload's behaviour. A collection whose own `create` rule lets an anonymous request through keeps
its route.
its route. The plugin puts its own `POST /first-register` endpoint in front of Payload's on every auth
collection (`buildFirstUserEndpoint`): it refuses, or hands the request to Payload's handler. It does not read
the request path, so the spelling of the URL (`/First-Register`) changes nothing. A collection with
`endpoints: false` is left alone.
- **A fresh site:** whoever opens the panel first becomes the admin — create the first account right after the
first deploy.
- **What an existing site sees:** nothing, unless its own staff collection relied on Payload's default `create`
(non-admins creating accounts) — then give it a `create` rule or set `adminOnlyCreate: false`.
- `ipal-doctor --url` lists auth collections with open sign-up (`open-signup`, info).
- Building blocks: `staffCreateAccess`, `applyAdminOnlyCreate`, `buildFirstUserGuard`, `applyFirstUserRoute`,
`openSignUpCollections`.
- **`access.firstUserAdmin: false`** gives the first account the default role. If that role is below the panel
role, nobody could open the panel on a fresh site: with the default panel role the plugin then does **not**
apply it and says so at start; with `accounts.panelRole` set by you the config is refused at start. Set
`access.defaultRole: 'editor'`, or `accounts: { panelRole: false }`.
- **What an existing site sees:** nothing, unless its own staff collection relied on Payload's defaults
(non-admins creating accounts in a collection with the plugin's roles; accounts of another collection writing
to it) — then write the rule you want, or set `adminOnlyCreate: false` / `adminOnlyWrite: false`.
- `ipal-doctor --url`: `open-signup` (info) lists auth collections with open sign-up; `staff-accounts-open`
(error) names a staff collection an account of another collection may create in, update or delete from
(the rules are off, or your own rule is wider).
- Building blocks: `staffCreateAccess`, `staffUpdateAccess`, `sameStaffCollectionAccess`, `hasPluginRoles`,
`applyStaffAccountAccess`, `buildFirstUserEndpoint`, `applyFirstUserRoute`, `openSignUpCollections`,
`staffCollectionsOpenToOthers`.
- **Check:** `curl -X POST <site>/api/members/first-register -H 'content-type: application/json' -d
'{"email":"x@example.com","password":"a-long-password-1"}'` → `403`; the same for `/api/users` → `403`.
'{"email":"x@example.com","password":"a-long-password-1"}'` → `403`, also as `/First-Register`; the same for
`/api/users` → `403`. Logged in as a visitor account: `PATCH /api/users/<id>` → `403`.
### Passwords (`accounts.password`, default 12 characters)
@@ -299,6 +334,9 @@ changed. The message is in the panel's language, English or Polish ("The passwor
characters."; texts `passwordTooShort`, `passwordIsEmail` in `i18n.translations.<lang>.ipal`).
- `password: { minLength: 16 }`; `password: false` = Payload's rule. Visitor collections are not touched.
- Checked against the account's address also where the request carries none: a change by id, a reset by e-mail
(the account is found by its token), a bulk update (every account it matches). A password that is not text
(a number, a list) is refused with the same message.
- No breached-password lookup (it would send part of a hash of every new password to an outside service);
build one on `checkPassword` / `buildPasswordRuleHook` if a project needs it.
- A script or seed that creates a staff account with a shorter password now fails with a validation error.
@@ -308,8 +346,8 @@ characters."; texts `passwordTooShort`, `passwordIsEmail` in `i18n.translations.
## Turn off, override, extend
- **Account rules:** `accounts: false`, or one by one — `panelRole`, `adminOnlyCreate`, `firstUserRoute`,
`password` (above).
- **Account rules:** `accounts: false`, or one by one — `panelRole`, `adminOnlyCreate`, `adminOnlyWrite`,
`firstUserRoute`, `password` (above).
- **Turn off:** leave out `access` — no `roles` field, the auth collection keeps Payload's rules
(or yours). `access.firstUserAdmin: false` stops giving admin to the first account.
- **Override:** `access.staffCollections` (who is staff), `access.authAccess` (injected collection), your own auth collection (wins whole),