K-3: docs — fields that hold a list, a relationship counts, a rule of your own replaces the protection, known limitations
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
c3d95988e1
commit
4c7b722aed
+19
-8
@@ -290,21 +290,22 @@ list the staff accounts, and lift the lock after failed logins.
|
||||
|
||||
| The collection | `create`, `delete`, `unlock` | `update` | the `roles` field (when it has no `access.update`) | `read`, `readVersions` |
|
||||
|---|---|---|---|---|
|
||||
| carries **the plugin's roles**: it is `access.authCollection`, or has a `roles` select whose values are all `user` / `editor` / `admin` (`hasPluginRoles`), **or one whose accounts can hold `editor` or `admin`**, whatever else its `roles` field offers (`canHoldStaffRole`, below) | an admin (`staffCreateAccess`) | an admin, or the account itself (`staffUpdateAccess(slug)`) | only an admin changes it (`rolesByAdminOnly`) | a staff account (`staffReadAccess`) |
|
||||
| carries **the plugin's roles**: it is `access.authCollection`, or has a `roles` select **with `hasMany`** whose values are all `user` / `editor` / `admin` (`hasPluginRoles`), **or one whose accounts can hold `editor` or `admin`**, whatever else its `roles` field offers (`canHoldStaffRole`, below) | 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 that hold neither `editor` nor `admin`** (`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.
|
||||
|
||||
**A `roles` field that can hold `editor` or `admin`.** The plugin's checks go by the **value on the account**
|
||||
(`isAdmin`, `isEditor`): an account of a staff collection whose `roles` hold `admin` is a plugin admin, one that
|
||||
holds `editor` edits the site's settings — whatever else the field offers. So wherever an account of the
|
||||
collection **can** hold one of the two, the collection gets the admin rules (`canHoldStaffRole`):
|
||||
(`isAdmin`, `isEditor`): an account of a staff collection whose `roles` — an **array** — holds `admin` is a plugin
|
||||
admin, one that holds `editor` edits the site's settings, whatever else the field offers. So wherever an account
|
||||
of the collection **can** hold one of the two, the collection gets the admin rules (`canHoldStaffRole`):
|
||||
|
||||
| The collection's `roles` field | Rules |
|
||||
|---|---|
|
||||
| a select with `editor` or `admin` among its values — `user, editor, admin, boss`; `viewer, editor` | the admin rules (first row above) |
|
||||
| a field whose values cannot be listed — text, json, a select without options: anything can be written there | the admin rules |
|
||||
| a select whose values are all your own and hold neither — `lead, member` | "an account of that same collection" (second row) |
|
||||
| a select **with `hasMany`** and `editor` or `admin` among its values — `user, editor, admin, boss`; `viewer, editor` | the admin rules (first row above) |
|
||||
| a field that holds a list whose values cannot be listed — text with `hasMany`, json, a relationship with `hasMany` (to documents whose ids are text, the ids are the roles), a select without options, a type the plugin does not know: anything can be written there | the admin rules |
|
||||
| a select with `hasMany` whose values are all your own and hold neither — `lead, member` | "an account of that same collection" (second row) |
|
||||
| a field that holds **one** value — a select, text or relationship without `hasMany`, a radio, a number (`rolesAreAList` is false) | second row. The plugin counts roles only from an array: an account whose `roles` is the single value `admin` is **not** a plugin admin, so there is nothing of the plugin's to protect and the collection's accounts keep managing each other |
|
||||
| no `roles` field | second row; every account of it is an admin to the plugin (below) |
|
||||
|
||||
Otherwise any account of such a collection could hand the value out: create an `admin` and be in Site
|
||||
@@ -315,10 +316,20 @@ plugin's — such an account no longer creates, deletes or unlocks accounts ther
|
||||
anybody's roles. Give it what it needs with rules of your own (`access.create` / `update` / `delete`, field
|
||||
access on `roles`), which win as always. In a collection where nobody can be an `admin` (`viewer, editor`) the
|
||||
accounts are managed by an admin of another staff collection — the panel's.
|
||||
|
||||
**A rule of your own replaces the protection for that operation.** The plugin fills only what you left open: with
|
||||
your own `create: ({ req }) => Boolean(req.user)` any account still creates an `admin` there; with your own
|
||||
`access.update: () => true` on the `roles` field an account still raises itself. And the plugin sees the field's
|
||||
declared values, not your code: a value that a hook of yours puts into `roles` (an `afterRead` that returns
|
||||
`['admin']` from a checkbox, a virtual field) is not seen — such a collection is judged by its declared field.
|
||||
|
||||
**If no staff account holds `admin` at all**, nobody can create, delete or unlock accounts in such a collection.
|
||||
The start log says so: `[ipal] No staff account holds the role "admin", so NOBODY can create, delete or unlock
|
||||
accounts in "…"`. Way out: give one account the role with a script (`payload.update`, Local API), or write the
|
||||
collection's own rules.
|
||||
collection's own rules. The check asks each staff collection in the way its field allows (a count for a select,
|
||||
reading the accounts for text / json / relationship fields, up to 1000 of them); where it cannot check a
|
||||
collection it says `[ipal] Could not check whether an account of "…" holds the role "admin"` instead and claims
|
||||
nothing.
|
||||
|
||||
**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
|
||||
|
||||
Reference in New Issue
Block a user