# access Role-based access control: hierarchy **admin > editor > user**. The plugin injects a fixed `roles` field into the client's auth collection and provides predicates and ready access functions (collection-level and field-level). ## Config (payload.config.ts) ```ts ipalKit({ access: { authCollection: 'users', // slug of your auth collection (required) // defaultRole: 'user', // role of new accounts // firstUserAdmin: true, // the account from "Create first user" → admin // authAccess: { … }, // access of the injected auth collection (your keys win) // staffCollections: ['partners'], // more auth collections whose accounts are staff }, // globalOverrides: { … }, // access / admin / hooks / fields of the plugin's globals }) ``` | Option | Default | What it does | |---|---|---| | `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 — 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 | The `roles` field (select hasMany, required, `saveToJWT`): readable without limits; only an admin can set and change it — also on account creation, so an open sign-up cannot push `roles: ['admin']` through. The first-user screen and the Local API (seed) run with `overrideAccess`. An account without roles meets no threshold (not even `'user'`); `authenticated` only checks that someone is logged in. **Auth collection when the project has none.** The plugin adds a minimal collection (`auth: true`, `admin.useAsTitle: 'email'`) with the slug `access.authCollection` (or `twoFactor.collectionSlug`, `admin.user`, `'users'`). The project's own collection with that slug always wins whole. ## What the plugin locks down by itself | Resource | Read | Write | How to change | |---|---|---|---| | auth collection **injected** by the plugin, with roles | admin: everyone; other accounts **of that collection**: only themselves (`adminOrSelfIn`) | `create` / `delete` / `unlock`: admin; `update`: admin or self | `access.authAccess`, or your own collection | | Site settings, Cookie banner, Notifications | public | `editor+` | `globalOverrides` | | Site integrations | admin | admin | `globalOverrides` | | Forms | public (Emails tab only `editor+`) | `editor+` | `forms.formOverrides.access`, the Emails field in `formOverrides.fields` | | Form submissions | `editor+` | REST `create`: logged-in users; `delete`: admin | `forms.formSubmissionOverrides.access` | ```ts import { authenticated } from '@intecion/ipal-kit' ipalKit({ access: { authCollection: 'users', authAccess: { read: authenticated } }, // editors see the account list globalOverrides: { notifications: { access: { update: authenticated } }, // any logged-in account edits the texts 'site-settings': (g) => ({ ...g, admin: { ...g.admin, group: 'Configuration' } }), }, }) ``` The project's own auth collection keeps its own `access` — the plugin only adds the `roles` field. Give it at least `update: adminOrSelfIn('users')`, `delete: adminOnly`, `create: adminOnly`, `unlock: adminOnly`: Payload's default lets any logged-in account change the email and password of another account and unlock any account. A collection injected **without** `access` (no roles) keeps Payload's default rules — without roles all accounts are equal. ## Who is staff **Staff collections** are the auth collections whose accounts work in the panel: - the one the admin panel logs in with (`admin.user`; Payload's default is the **first** auth collection in the list — set `admin: { user: 'users' }` yourself as soon as the project has two); - the one that carries the plugin's roles (`access.authCollection`); - the ones named in `access.staffCollections`. An account of **any other auth collection** — `customers`, `members`, a client zone — is a visitor to the plugin. **Nothing in the plugin counts a role for it**, also when its own collection has a `roles` field with the value `admin`: not `userMeetsRole`, not `isAdmin` / `isEditor` / `hasMinimumRole`, not `adminOnly`, `adminOrEditor`, `requireRole`, `adminOrSelf`, `adminOrSelfIn` or the `…Field` variants, not the `roles` field itself. The staff-collection check always comes first. The plugin's own staff features — Site integrations, the settings globals, form submissions, consent records, stats, the cookie scanner, `/api/ipal/test-email` — check with `userMeetsRole(req, minimum)`, in this order: 1. the account belongs to a staff collection; 2. with 2FA on: the account has set TOTP up and has entered the code in this session ([security.md](./security.md) → "What the second factor covers", "Setup required"); 3. it holds at least the role `minimum` — **or** its collection has no `roles` field at all. Then every account of that staff collection passes, as in Payload's default (without roles all accounts are equal). What follows: - **Without `access`** there is no `roles` field, so `isAdmin` always returns `false` and rule 3 keeps the staff features reachable: every account of the panel collection is admin to the plugin. To narrow that without roles: `globalOverrides` for the globals, `forms.formSubmissionOverrides` for submissions, or add `access` to get roles. - **A second staff collection** (e.g. `partners` who edit content): name it in `access.staffCollections`. That is the one switch that makes its roles count. Without a `roles` field every partner passes every staff check, admin ones included; to tell them apart add the field: `fields: [buildRolesField('editor')]` in that collection. **2FA covers one collection** (`twoFactor.collectionSlug`, by default the panel's): accounts of a further staff collection are staff with a password alone. ipalKit says so in the log at start (`[ipal] 2FA covers "users" only…`); name such a collection only when that is acceptable. - **Payload's own default** for a collection or global without `access` is "any logged-in account" — an account of a visitor collection included. In a project with a second auth collection give every collection and global explicit `access` (`adminOrEditor`, `requireRole(…)`, …). - **A visitor collection that should reach one thing** (e.g. customers read their own form submissions): do not make it staff. Write that one rule yourself — `forms.formSubmissionOverrides.access.read`, `globalOverrides`, `collectionOverrides` of the module — and check `req.user.collection` in it. - **A user object you build yourself** (Local API with `overrideAccess: false`, a custom auth strategy) must carry `collection`: `{ ...doc, collection: 'users' }`. Payload's own strategies and `payload.auth()` set it. An account without it is not staff. > **Changed in 1.16.4.** Before, a role or the "no roles field" rule counted for an account > of any auth collection: an account of a second auth collection passed staff checks — every one when its > collection had no `roles` field, and the matching ones when it had its own `roles` field. A project with one > auth collection sees no difference. A project that relied on a second collection being staff sets > `access.staffCollections`. ## Predicates (front end / hooks / access) ```ts import { isAdmin, isEditor, hasMinimumRole, staffCollectionSlugs, userMeetsRole } from '@intecion/ipal-kit' isAdmin(req.user, req.payload) // a staff account with the admin role isEditor(req.user, req.payload) // editor or admin (hierarchy) hasMinimumRole(req.user, 'editor', req.payload) // at least editor userMeetsRole(req, 'admin') // the plugin's staff check: staff collection, second factor, role ("Who is staff") staffCollectionSlugs(req.payload) // ['users', …] ``` They take a loosely typed user (like `req.user`) and read `roles` defensively. The last argument tells them which collections are staff: | Where you call it | Pass | Without it | |---|---|---| | access functions, hooks, endpoints (server, the config is loaded) | `req.payload` | works: the staff collections of the config `ipalKit` built in this process. With two different configs in one process, only collections that are staff in **both** count — pass `req.payload` to get that config's own answer | | client components — import from **`@intecion/ipal-kit/client`** | the config from `useConfig()` (it has `admin.user`, the panel's login collection), or `{ staffCollections: ['users', …] }` | **always `false`** — the browser bundle has no config | | Next middleware / `proxy.ts`, the edge runtime | `{ staffCollections: ['users'] }` | **always `false`** — the config is not loaded there | ```tsx 'use client' import { isAdmin } from '@intecion/ipal-kit/client' // not '@intecion/ipal-kit' import { useAuth, useConfig } from '@payloadcms/ui' export function AdminOnlyHint() { const { config } = useConfig() const { user } = useAuth() // a hint only — the server decides return isAdmin(user, config) ?

…

: null } ``` - **The import in a client component is `/client`** (`hasMinimumRole`, `isAdmin`, `isEditor`, the type `Role`). The main entry reaches `server-only` modules: with `next build --webpack` it fails with `'server-only' cannot be imported from a Client Component module` (Turbopack builds it, but the import does not belong there either). In 1.16.4–1.16.6 `/client` does not have them — upgrade. - **On the server** (config, hooks, access functions, endpoints, server components, `proxy.ts`) import from `@intecion/ipal-kit`: `/client` is a `'use client'` entry, a server component that calls a function from it fails. - `useConfig()` carries `admin.user` only (Payload strips `config.custom` from the client config). Accounts of `access.staffCollections` need the list: `isAdmin(user, { staffCollections: ['users', 'partners'] })`. They fail closed: where the staff collections are not known, nobody is staff, and an account without `collection` is nobody. `isAdmin` and the others do **not** check the second factor; `userMeetsRole` and every `access` function in the config do. ## Ready access functions ### Collection-level (return boolean | Where) ```ts import { adminOnly, adminOrEditor, adminOrSelf, adminOrSelfIn, requireRole, authenticated } from '@intecion/ipal-kit' export const Articles = { slug: 'articles', access: { read: authenticated, create: adminOrEditor, update: adminOrEditor, delete: adminOnly, }, // ... } // Users: everyone sees themselves, an admin sees everyone. // adminOrSelfIn(slug): "self" = an account of THAT collection. Use it for an auth collection whenever // the project has more than one: adminOrSelf only compares ids, and with numeric ids (Postgres, SQLite) // customer no. 5 would match staff account no. 5. access: { read: adminOrSelfIn('users') } access: { read: adminOrSelf } // fine with a single auth collection // any minimum threshold access: { update: requireRole('editor') } ``` ### Field-level (return boolean) ```ts import { adminOnlyField, adminOrEditorField, requireRoleField } from '@intecion/ipal-kit' { name: 'internalNote', type: 'textarea', access: { read: adminOnlyField, update: adminOnlyField }, } ``` ## Hierarchy ```ts import { ROLE_HIERARCHY } from '@intecion/ipal-kit' // ['user', 'editor', 'admin'] — a higher role meets a lower role's requirement ``` ## Building blocks: buildRolesField, injectRoles, applyGlobalOverrides ```ts import { applyGlobalOverrides, buildRolesField, injectRoles } from '@intecion/ipal-kit' buildRolesField('user', { firstUserAdmin: true }) // just the roles field — for your own collection injectRoles(config, { authCollection: 'members' }) // add the field to a collection in a finished config applyGlobalOverrides(globals, { notifications: { … } }) // the same logic as the globalOverrides option ``` Types: `AccessOption`, `Role`, `GlobalOverride`, `GlobalOverrides`, `IpalGlobalSlug`. ## Account rules (`accounts`) Rules for the accounts of the staff collection. All on by default; each has its own switch, and `ipalKit({ accounts: false })` turns them all off. ```ts 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` / `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 // accounts: false, // none of the rules }) ``` ### Who may open the panel (`accounts.panelRole`, default `'editor'`) The lowest role, `user`, is what a new account gets (`access.defaultRole`) and has no business in the panel. The panel opens for `editor` and above: it is Payload's `access.admin` on the collection that carries the roles. An account that holds only `user` (or no role) logs in and sees Payload's "Unauthorized" screen. **The API is not touched** — such an account still gets over REST / GraphQL what its role allows. The rule looks at the role, not at the second factor, so the 2FA screens stay reachable. - **What an existing site sees on the first start:** the log line `[ipal] N account(s) of "users" are below the role "editor" and cannot open the admin panel` — give those people `editor`, or set `panelRole: 'user'`. When **no** account has the role it is an error (`NOBODY can open the admin panel`): give one account the role with a script (`payload.update`, Local API) or set `accounts: { panelRole: false }` and redeploy. - `'admin'` = admins only; `'user'` or `false` = everyone, as before. Needs `access` (the roles). Your own `access.admin` on the collection, or `access.authAccess.admin`, wins. Building blocks: `panelAccess(role)`, `applyPanelRole`, `resolvePanelRole`, `countBelowPanelRole`, `DEFAULT_PANEL_ROLE`. - **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.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`, `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) | |---|---|---| | 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) | 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//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 | **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`, `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 **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` — 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 `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. If your own code gives rights by that value, write the collection's own rules | | 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 integrations and every other staff collection, or create an `editor` and change the site's settings. (Until this change these collections got the second row, and an account with the lowest role could do exactly that.) **What it means for your accounts:** a role the plugin does not know (`boss`, `viewer`) carries no rights of the plugin's — such an account no longer creates, deletes or unlocks accounts there, changes another account or 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. 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 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 config goes live — at start and on every dev reload. The log says exactly what was put: `[ipal] "late-staff" was added after ipalKit: put on it — access rules for create, update, delete, unlock, read, readVersions, roles; the password rule; the first-user endpoint.` One difference from a collection of your own config: by then Payload has sanitized the collection and filled every missing rule with its default, and that default cannot be told from a rule somebody wrote (a production build renames every function). So the plugin does not guess: **its rule is put in front of whatever rule is there, and both must allow** (`bothAllow`). With Payload's default behind it the result is the plugin's rule; a rule of the collection's own is kept and can only narrow it. To keep a late collection's rules exactly as they are — an open `create`, a wider `read` — say so on the collection: `custom: { ipal: { accountRules: false } }` (the password rule and the first-user endpoint still apply), or list that plugin before ipalKit. **A collection of your own config that becomes staff later** — it is in the config, you did not name it as staff, and a plugin listed after ipalKit sets `admin.user` to it — is handled at the same moment, with one difference: the plugin saw it at config time and wrote down which operations had a rule of yours (the marker's `own`). **Those rules stay exactly as written; an operation that had no rule gets the plugin's** — the same result as for a collection named in `access.staffCollections`, and its `roles` field is guarded where the plugin's `update` rule is the one in force. The log: `[ipal] "people" became a staff collection after ipalKit ran: put on it — access rules for update, delete, unlock, read, readVersions, roles; the password rule. Its own rules for create are kept as written.` Without rules of its own such a collection ran on Payload's defaults before (any signed-in account, a customer included, created and changed panel accounts). Simpler and clearer: name the collection in `access.staffCollections`, or list that plugin before ipalKit. Verify: sign in as an account of a non-staff collection and `POST /api/` — 403 unless your own `create` rule lets it through. **A copy of a staff collection** — a later plugin that spreads one into a new slug (`{ ...staff, slug: 'copy' }`), or a new collection that reuses a staff collection's `access` object — brings along rules the plugin wrote for the ORIGINAL: "an account of `staff`", "the account itself" = one of the original's. The plugin sees them by a mark it puts on its own functions (`staffRuleOf(rule)` → `{ slug, self }`; the mark counts only on the very function it was made for, so a wrapper of yours around a plugin rule is your rule). What it does is one thing, in every case: > **The plugin's rule for THIS collection goes in front of the rule that is there, and both must allow.** > Nothing is replaced and nothing is rewritten. | The copy | Where the plugin's rule goes in front | |---|---| | named in `access.staffCollections` | of every rule — as on any late staff collection | | not named as staff, or with `custom: { ipal: { accountRules: false } }` | only of the rules the plugin wrote for the original; your own rules there stay as they are | | its `roles` field | guarded on every copy (the plugin's roles: only an admin changes them; others: never one's own) unless the field has an `access.update` of its own — then the guard goes in front only of a rule the plugin wrote for the original | So a copy is never opened wider than its rules were before, and never wider than the plugin's rule — whatever role values it has, whichever operation it uses a copied rule for, however it wraps it. The original's account with the same id is not "the account itself" in the copy. **The cost, and the one line that pays it:** a copied rule that says "an admin, or the account itself" still means the ORIGINAL's accounts, so in the copy only an admin passes it — the copy's own accounts cannot edit themselves until the copy says who may: ```ts import { adminOrSelfIn } from '@intecion/ipal-kit' // in the plugin that makes the copy: { ...staff, slug: 'copy', access: { ...staff.access, update: adminOrSelfIn('copy') } } ``` A rule you write there is not marked, so on a staff copy it is combined with the plugin's rule for `copy` ("an admin, or the account itself" of the copy) and works. The password rule is on a copy once (`isPasswordRuleHook`). The marker `custom.ipalAccounts` (`{ slug, staff, own? }`, type `AccountsMarker`) records which collection the plugin has handled, whether as staff, and — for a collection that was not staff at config time — which operations had a rule of the project's then (`own`): a copy carries the original's marker and is handled under its own slug; in `next dev` a collection named as staff in an edit is handled on the reload. A marker for the collection's own slug means "handled" — only your own config can write one, like `accountRules: false`. **A slug in `access.staffCollections` or `access.authCollection` that is not an auth collection of the config:** Payload does not start. The log names the slug and the auth collections it knows. The process stays up, but every Payload call fails — `/api/health` answers 503, `/api/*` and the panel 500; a page that needs no Payload call may still answer. With a health check ([deployment.md](./deployment.md) §4.4) Coolify keeps the old container serving, so a wrong slug never goes live (`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 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. - **`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-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`, `staffReadAccess`, `sameStaffCollectionAccess`, `rolesByAdminOnly`, `rolesNotOwn`, `bothAllow`, `hasPluginRoles`, `applyStaffAccountAccess`, `adoptLateAuthCollections`, `unknownStaffCollections`, `buildFirstUserEndpoint`, `applyFirstUserRoute`, `openSignUpCollections`, `staffCollectionsOpenToOthers`, `staffCollectionsOnOwnRoles`. - **Check:** `curl -X POST /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/` 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) When a password is **set** on a staff collection — a new account, the first-user screen, a change, a reset by e-mail; in the panel, over the API and through the Local API — it must have at least 12 characters and must not be the account's own e-mail address (Payload's own rule is 3 characters). **Existing passwords are never checked:** an account with a shorter one keeps logging in, and meets the rule the next time its password is changed. The message is in the panel's language, English or Polish ("The password must have at least 12 characters."; texts `passwordTooShort`, `passwordIsEmail` in `i18n.translations..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. - Building blocks: `checkPassword`, `buildPasswordRuleHook`, `applyPasswordRule`, `resolvePasswordRule`, `DEFAULT_PASSWORD_MIN_LENGTH`. - **Check:** create an account with an 11-character password → "The password must have at least 12 characters.". ## Turn off, override, extend - **Account rules:** `accounts: false`, or one by one — `panelRole`, `adminOnlyCreate`, `adminOnlyWrite`, `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), `globalOverrides` (globals), `forms.formOverrides` / `formSubmissionOverrides` (forms), `defaultRole`. The role hierarchy (`ROLE_HIERARCHY`) is fixed. - **Extend:** `requireRole` / `requireRoleField`, `adminOrSelfIn`, predicates (`userMeetsRole`, `staffCollectionSlugs`), `buildRolesField`, `injectRoles`, `applyGlobalOverrides` in your own collections and globals. - **Check:** log in with a `user` account → `PATCH /api/globals/site-settings` = 403, `DELETE /api/users/` = 403; the account from "Create first user" has the `admin` role.