IF Commons GitHub

sql/extensions/operations/identity/decide

Written to: 4 requirements: 4 proved, 0 partly, 0 failing, 0 with no test recorded. 0041-identity-authorize FR-001, 0041-identity-authorize FR-002, 0041-identity-authorize FR-003, 0041-identity-authorize FR-005

The decision engine of identity (commons data 0041-identity-authorize): one decide(principal, action, resource, context) that answers for a person, a machine, a device, an agent or a group alike. Permits come from roles (direct, through groups, through role inheritance), from relationships and from policies; any refusal wins; what is unknown never allows. A principal acting under a delegation can do only what every delegation of the chain passes on and what the person at its root can do themselves at that moment. Every decision says why.

Source: commons/data/sql/extensions/operations/identity/decide.ts

1 of 5 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Decisioninterfaceno test imports it
interface Decision

What was decided, and why.

MemberTypeWhat it is
effect"allow" | "deny"
reasonsreadonly string[]
obligationsreadonly ("approval" | "stepUp")[]What must happen before an allowed action is done.
refsreadonly string[]The roles, policies, tuples and delegations that decided.
decidefunction
function decide(tx: Tx, req: Request): Promise<Decision>

Decides.

ParameterWhat it is
txa transaction
reqwhat is asked

Returns: the decision, with why

Imported by 13 tests of the run (13 passed, 0 failed): the library's results

identityAuthorizeconstno test imports it
const identityAuthorize: (now: () => string) => (tx: Tx, caller: string, permission: string, tenant: string | undefined) => Promise<boolean>

The authorizer of the operations runtime, from the engine: it allows a caller who is allowed the permission in the tenant.

ParameterWhat it is
nowthe clock

Returns: the authorizer

matchesconstno test imports it
const matches: (pattern: string, action: string) => boolean

Whether a pattern (an exact permission, or a prefix ending *) matches an action.

Requestinterfaceno test imports it
interface Request

What is asked.

MemberTypeWhat it is
principalstring
actionstringThe permission, as resource:action.
tenantstring
resource?{ readonly type: string; readonly id: string; }
context?Readonly<Record<string, unknown>>Attributes of the environment and the action, by key, such as environment.ip.
delegation?stringThe delegation the principal acts under.
nowstringThe time of the decision.

Titles, headings, exports, tables, columns and requirements. Esc closes.