Skip to main content

PolicyEngine

@webda/iam


Class: PolicyEngine

Defined in: packages/iam/src/engine.ts:51

An immutable snapshot of the compiled policies

Properties​

enforcer​

protected enforcer: Enforcer

Defined in: packages/iam/src/engine.ts:55

the Casbin enforcer

Methods​

decide()​

decide(principals, operationId, ctx): Promise<string | true>

Defined in: packages/iam/src/engine.ts:106

Decide whether principals may call an operation

Parameters​

principals​

string[]

the caller principals

operationId​

string

the operation id

ctx​

IAMRequestContext

the request context

Returns​

Promise<string | true>

true when allowed, otherwise the refusal reason; an evaluation error is a refusal


build()​

static build(policies, attachments): Promise<PolicyEngine>

Defined in: packages/iam/src/engine.ts:63

Build an engine from compiled rows

Parameters​

policies​

PolicyRow[]

the p rows

attachments​

AttachmentRow[]

the g rows

Returns​

Promise<PolicyEngine>

the engine