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 itinterface Decision
What was decided, and why.
| Member | Type | What it is |
|---|
effect | "allow" | "deny" | |
reasons | readonly string[] | |
obligations | readonly ("approval" | "stepUp")[] | What must happen before an allowed action is done. |
refs | readonly string[] | The roles, policies, tuples and delegations that decided. |
function decide(tx: Tx, req: Request): Promise<Decision>
Decides.
| Parameter | What it is |
|---|
tx | a transaction |
req | what 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 itconst 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.
| Parameter | What it is |
|---|
now | the clock |
Returns: the authorizer
matchesconstno test imports itconst matches: (pattern: string, action: string) => boolean
Whether a pattern (an exact permission, or a prefix ending *) matches an action.
Requestinterfaceno test imports itinterface Request
What is asked.
| Member | Type | What it is |
|---|
principal | string | |
action | string | The permission, as resource:action. |
tenant | string | |
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? | string | The delegation the principal acts under. |
now | string | The time of the decision. |