A staff collection whose accounts can hold editor or admin gets the admin rules (H-2, J-3)
In the released 1.16.7. The plugin's checks go by the value on the account, but a project's own staff collection
without rules got the admin rules only when ALL its role values were the plugin's; otherwise 'an account of this
collection' could create, change and delete accounts. Measured on bc0fa65 (SQLite; the first shape also on Postgres
and MongoDB, 2FA off and on): with roles user/editor/admin/boss, with a text and with a json roles field, config-time
and added by a later plugin, an account with the role user creates an admin (201) who reads Site integrations, changes
another staff collection's roles and lists the panel's accounts (200 / 200 / 200), takes the admin over and deletes it;
with viewer/editor a viewer creates an editor who gets past the access rule of Site settings.
canHoldStaffRole(collection): a roles select with editor or admin among its values, or a roles field whose values
cannot be listed. Then: create / delete / unlock an admin, update an admin or the account itself, roles only by an
admin. A project's own rules win. A warning at start when no staff account is an admin and such a collection exists.
The built-site fixture gets a config-time and a late collection of that kind; nothing here touches copied collections.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
01219b69d3
commit
be2e6d52d9
+12
-1
@@ -15,7 +15,7 @@ import { buildSiteSettings } from './globals/SiteSettings/index.js'
|
||||
import { adminOnly, adminOrSelfIn, injectRoles, registerStaffCollections, staffCollectionSlugs } from './modules/access/index.js'
|
||||
import { applyPanelRole, countBelowPanelRole, resolvePanelRole } from './modules/access/panelRole.js'
|
||||
import { applyPasswordRule, buildPasswordRuleHook, resolvePasswordRule } from './modules/access/passwordRule.js'
|
||||
import { adoptLateAuthCollections, applyFirstUserRoute, applyStaffAccountAccess, markSeenAuthCollections, unknownStaffCollections } from './modules/access/selfRegistration.js'
|
||||
import { adoptLateAuthCollections, applyFirstUserRoute, applyStaffAccountAccess, markSeenAuthCollections, staffCollectionsNobodyManages, unknownStaffCollections } from './modules/access/selfRegistration.js'
|
||||
import { ROLE_HIERARCHY } from './modules/access/types.js'
|
||||
import { applyAdminI18n } from './modules/admin-i18n/apply.js'
|
||||
import { buildAdminImageEndpoints } from './modules/branding/adminImages.js'
|
||||
@@ -935,6 +935,17 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
'Every account of the login collection can open the panel. To keep the lowest role out, set access.defaultRole to \'editor\' or drop access.firstUserAdmin: false (docs/access.md "Account rules").',
|
||||
)
|
||||
}
|
||||
// Staff collections on the admin rules while no staff account is an admin: nobody can manage their accounts.
|
||||
if (accounts) {
|
||||
const stuck = await staffCollectionsNobodyManages(payload as never, staffCollectionSlugs(payload), options.access?.authCollection)
|
||||
if (stuck.length) {
|
||||
payload.logger.warn(
|
||||
`[ipal] No staff account holds the role "admin", so NOBODY can create, delete or unlock accounts in ${stuck.map((s) => `"${s}"`).join(', ')} ` +
|
||||
"(only an admin does there: the collection's roles can hold \"editor\" or \"admin\"). Give one account the role with a script " +
|
||||
'(payload.update, Local API), or write the collection\'s own access.create / update / delete rules (docs/access.md "Account rules").',
|
||||
)
|
||||
}
|
||||
}
|
||||
// The panel role: tell a site how many of its accounts the rule keeps out of the panel.
|
||||
if (panelRoleFor) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user