Copied staff collections: the plugin's rule goes in front, nothing is replaced (a rule that cannot widen)
A plugin listed after ipalKit that copies a staff collection under a new slug, or reuses its access object, brings
rules the plugin wrote for the ORIGINAL. On 1.16.7 the copy also carried the boolean 'seen' marker and was left
alone: 'the account itself' then meant an account of the original — with numeric ids the original's account with
the same id changed the copy's account (17 of 40 measured shapes).
Design: the plugin never replaces and never rewrites a rule on such a collection. It puts its rule for the copy's
own slug in front, and both must allow: on a copy named as staff in front of every rule; on a copy that is not
staff or keeps its own rules (custom.ipal.accountRules: false) in front of the rules marked as the plugin's for
another collection. The roles field of every copy is guarded. The mark on the plugin's functions says only
{ slug, self }; custom.ipalAccounts says { slug, staff } (a collection named as staff during next dev is handled
on the reload). The plugin's rules are marked before its 2FA guard, which carries the mark.
Accepted cost: a copy's own account cannot edit itself through a copied rule (as on 1.16.7); the copy writes
access.update — one documented line.
Proof: test/accountCopyTableSuite.ts — 40 shapes x accounts x operations, each row not wider than the measurement
taken on 1.16.7 (test/fixtures/copyRulesBaseline.json) and not wider than the plugin's rule; 2FA off and on.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
4c7b722aed
commit
8dcc123b99
+12
-2
@@ -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, staffCollectionsNobodyManages, unknownStaffCollections } from './modules/access/selfRegistration.js'
|
||||
import { adoptLateAuthCollections, applyFirstUserRoute, applyStaffAccountAccess, markSeenAuthCollections, markStaffRules, 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'
|
||||
@@ -159,6 +159,11 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
: {}),
|
||||
admin: { useAsTitle: 'email' },
|
||||
auth: true,
|
||||
// these rules are the plugin's, written for this slug (marked as such when ipalKit finishes) — not the ones
|
||||
// the project passed in access.authAccess
|
||||
...(hasRoles
|
||||
? { custom: { ipalAccountRules: { slug: authSlug, applied: ['create', 'delete', 'read', 'unlock', 'update'].filter((k) => !(k in (options.access?.authAccess ?? {}))), ownRoles: false } } }
|
||||
: {}),
|
||||
fields: [],
|
||||
},
|
||||
]
|
||||
@@ -891,6 +896,8 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
// collections (wrapped by the package already; twice is harmless), the
|
||||
// plugin's globals and collections, the form builder's.
|
||||
if (secondFactorGuard) {
|
||||
// the plugin's account rules get their mark first (the 2FA package has wrapped them by now): the guard carries it over
|
||||
config = markStaffRules(config)
|
||||
config = guardConfigAccess(config)
|
||||
}
|
||||
|
||||
@@ -987,7 +994,10 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
}
|
||||
|
||||
// Every auth collection of this config has been seen: what appears later is a late one (adoptConfig).
|
||||
if (accounts) {config = markSeenAuthCollections(config)}
|
||||
if (accounts) {
|
||||
const panel = config.admin?.user ?? (config.collections ?? []).find((c) => c.auth)?.slug
|
||||
config = markSeenAuthCollections(config, staffCollectionSlugs({ admin: { user: panel }, custom: config.custom }))
|
||||
}
|
||||
return config
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user