Access Control (ABAC)
Configuard filters rows per item as it builds. Each row declares an
accessor — system, application, or all — and the client constructing the
Configuard declares its own. Only rows the client is allowed to see make it
into the built object.
- A
systemclient seessystemandallitems. - An
applicationclient seesallitems, plusapplication/allitems whoseappAccessbit flags intersect the client’sappLevel(a bitwise&).applicationitems must declare anappAccess, and anapplicationclient must be constructed with anappLevel.
import { Configuard, AccessorType } from 'configuard';
// Application client flags (bitwise).const WEB = 1 << 0; // 0b001const MOBILE = 1 << 1; // 0b010const KIOSK = 1 << 2; // 0b100
const rows = [ { accessor: 'application', appAccess: WEB | MOBILE, key: 'ui.theme', type: 'string', listType: 'none', value: 'dark', editable: true, requiresReboot: false, encrypt: false }, { accessor: 'application', appAccess: KIOSK, key: 'kiosk.timeout', type: 'integer', listType: 'none', value: '30', editable: true, requiresReboot: false, encrypt: false }, { accessor: 'all', appAccess: null, key: 'app.name', type: 'string', listType: 'none', value: 'Acme', editable: true, requiresReboot: false, encrypt: false }];
// A mobile client (appLevel = MOBILE):const cfg = new Configuard(rows, { accessor: AccessorType.APPLICATION, appAccess: MOBILE });
cfg.has('ui.theme'); // true — (WEB|MOBILE) & MOBILE !== 0cfg.has('kiosk.timeout'); // false — KIOSK & MOBILE === 0cfg.has('app.name'); // true — `all` item, no appAccessAccessor Rules
Section titled “Accessor Rules”accessordefaults toapplicationwhen none is passed.- Constructing with
accessor: 'all'throws —alldescribes a row’s reach, not a client. A client is eithersystemorapplication. - An
applicationclient with noappLevelthrows. - An
applicationrow with noappAccessthrows when encountered during the build.
Metadata Is Access-Consistent
Section titled “Metadata Is Access-Consistent”The metadata accessors —
getMeta,
isEncrypted, and requiresReboot — only
answer for keys visible to this instance’s accessor, mirroring has(). They
return undefined/false for anything the client can’t see.
Property-Level Filtering
Section titled “Property-Level Filtering”ABAC here decides which rows a client gets. To filter the properties of the
built object further (per role, per attribute), combine it with
accesscontrol.