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
@@ -1,5 +1,7 @@
|
||||
import type { BasePayload, CollectionConfig, Config, GlobalConfig } from 'payload'
|
||||
|
||||
import { carryStaffRule } from '../../access/ruleMark.js'
|
||||
|
||||
/**
|
||||
* ipal-kit's own second-factor check, next to the access wrapper of
|
||||
* @clocklimited/payload-2fa.
|
||||
@@ -150,6 +152,8 @@ export function requireSecondFactor<T extends AnyAccess>(access?: T): T {
|
||||
return access ? access(args as never) : Boolean(args.req?.user)
|
||||
}) as unknown as Guarded
|
||||
wrapped[GUARDED] = true
|
||||
// the wrapper answers for the same rule: the plugin's mark on a staff account rule goes with it (access/ruleMark.ts)
|
||||
carryStaffRule(access, wrapped)
|
||||
return wrapped as unknown as T
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user