M1 review round 2: docs, agent guide, skills, changelog; the reference types without the removed field

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 00:39:24 +01:00
co-authored by Claude Fable 5.2
parent 7002ebbfa6
commit 3e44863c98
17 changed files with 206 additions and 150 deletions
+50 -25
View File
@@ -234,7 +234,8 @@ 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: { adminOnlyWrite: false }, // Payload's default `update` / `delete` / `unlock` there, roles field left alone
// accounts: { staffOnlyRead: false }, // Payload's default `read` 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
@@ -260,15 +261,16 @@ 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, or takes one over (`accounts.adminOnlyCreate`, `accounts.adminOnlyWrite`, `accounts.firstUserRoute`)
### Nobody creates an account for themselves, or takes one over (`accounts.adminOnlyCreate`, `accounts.adminOnlyWrite`, `accounts.staffOnlyRead`, `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, 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.
Payload's default for a collection without access rules is "any logged-in user" for `create`, `read`, `update`,
`delete` and `unlock` — an account of **any** auth collection. On a project's own staff collection a visitor
account (`customers`) could therefore create a staff account, `PATCH` a staff account's password and roles,
list the staff accounts, and lift the lock after failed logins.
| | Before | Now (default) |
|---|---|---|
@@ -277,6 +279,8 @@ Payload's default for a collection without access rules is "any logged-in user"
| 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) | 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 |
| A visitor account lists the accounts of such a collection, or unlocks one | **allowed** (Payload's default) | refused |
| An account of such a collection changes its **own** `roles` (the field has no access of its own) | **allowed** | refused — with the plugin's roles only an admin changes roles |
| `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 |
@@ -284,21 +288,39 @@ Payload's default for a collection without access rules is "any logged-in user"
**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 |
| The collection | `create`, `delete`, `unlock` | `update` | the `roles` field (when it has no `access.update`) | `read` |
|---|---|---|---|---|
| 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)`) | only an admin changes it (`rolesByAdminOnly`) | a staff account (`staffReadAccess`) |
| 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 | an account never changes its **own** (`rolesNotOwn(slug)`) | a staff account |
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.
Always "fully signed in": a session that still owes its second factor passes none of them.
- `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)`).
**Roles of your own — what the plugin does and does not hold.** It cannot rank `superadmin` against `writer`,
so inside such a collection it enforces one thing only: an account does not change its own roles. Everything
else that was allowed inside the collection stays allowed — **every account of it may still create an account
with any role, and change or delete another account**. That is a hole only you can close: write the
collection's `create` / `update` / `delete` rules and the field access of its `roles` field from your roles.
`ipal-doctor --url` names such a collection (`staff-own-roles`, warning). What the plugin closes for you is the
door for accounts of **other** collections.
**A staff collection without a `roles` field:** every account of it is an admin to the plugin (unchanged), so
it may also manage the accounts of the other staff collections. Give it the plugin's roles
(`buildRolesField`), or write its rules.
**A staff collection that a plugin listed after ipalKit adds** gets the same rules, the password rule and the
first-user endpoint when the site starts (and on a dev reload); the log says `[ipal] Account rules also put on
auth collections added after ipalKit: …`. There the plugin tells "no rule" from "your rule" by Payload's own
default function, so a rule you wrote stays. A slug in `access.staffCollections` or `access.authCollection`
that is **not an auth collection of the config stops the start** with the slug and the list of auth
collections (`unknownStaffCollections`).
- `adminOnlyCreate: false` = Payload's default `create`; `adminOnlyWrite: false` = Payload's default `update`,
`delete` and `unlock`, and the `roles` field is left alone; `staffOnlyRead: false` = Payload's default `read`.
The rules are put on the collections **before** the 2FA package wraps them, so they hold with 2FA on and off.
- `read` = "a fully signed-in account of a staff collection": staff sees staff (the panel needs it for
relationship fields and the account list), a visitor account sees nothing. The injected collection keeps its
stricter "admin or self". **A front end that shows staff accounts to logged-in visitors** needs its own `read`
rule on that collection (a rule you wrote wins), or `staffOnlyRead: false`.
- `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. The plugin puts its own `POST /first-register` endpoint in front of Payload's on every auth
@@ -314,15 +336,18 @@ closes is the door for accounts of **other** collections. Write your own rules t
- **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
- `ipal-doctor --url`: `open-signup` (info) lists auth collections with open sign-up; `staff-own-roles` (warning)
a staff collection with role values of its own on the default rules; `staff-accounts-open`
(error) names a staff collection an account of another collection may create in, read (a warning), update, delete from or unlock
(the rules are off, or your own rule is wider).
- Building blocks: `staffCreateAccess`, `staffUpdateAccess`, `sameStaffCollectionAccess`, `hasPluginRoles`,
`applyStaffAccountAccess`, `buildFirstUserEndpoint`, `applyFirstUserRoute`, `openSignUpCollections`,
`staffCollectionsOpenToOthers`.
- Building blocks: `staffCreateAccess`, `staffUpdateAccess`, `staffReadAccess`, `sameStaffCollectionAccess`,
`rolesByAdminOnly`, `rolesNotOwn`, `hasPluginRoles`, `applyStaffAccountAccess`, `adoptLateAuthCollections`,
`unknownStaffCollections`, `buildFirstUserEndpoint`, `applyFirstUserRoute`, `openSignUpCollections`,
`staffCollectionsOpenToOthers`, `staffCollectionsOnOwnRoles`.
- **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`, also as `/First-Register`; the same for
`/api/users` → `403`. Logged in as a visitor account: `PATCH /api/users/<id>` → `403`.
`/api/users` → `403`. Logged in as a visitor account: `PATCH /api/users/<id>` and `GET /api/users` → `403`. As a
non-admin of a staff collection: `PATCH` your own account with `roles` → the roles do not change.
### Passwords (`accounts.password`, default 12 characters)
@@ -347,7 +372,7 @@ characters."; texts `passwordTooShort`, `passwordIsEmail` in `i18n.translations.
## Turn off, override, extend
- **Account rules:** `accounts: false`, or one by one — `panelRole`, `adminOnlyCreate`, `adminOnlyWrite`,
`firstUserRoute`, `password` (above).
`staffOnlyRead`, `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),