IF Commons GitHub

accessPolicy

concept

A rule of attribute-based access: a condition over attributes that allows or refuses an action; a refusal always wins

Model identityAbac. Written in commons/data/models/identity-abac/mod.ts:87. Identified by accessPolicyId.

Governance: attributes

accessPolicyIdidentifierrequired

What identifies the policy, made by the application

Becomes the column access_policy_id of access_policy.

Written at commons/data/models/identity-abac/mod.ts:90

actionPatterntextrequired

The permission it is about: exact, or a prefix ending `*`

Becomes the column action_pattern of access_policy.

Written at commons/data/models/identity-abac/mod.ts:95

appliesTocode of principalKindoptional

The kind of principal it is about; every kind where it is empty

Becomes the column applies_to of access_policy.

Written at commons/data/models/identity-abac/mod.ts:94

definitiontextrequired

What the policy is for

Becomes the column definition of access_policy.

Written at commons/data/models/identity-abac/mod.ts:88

effectcode of policyEffectrequired

What it decides

Becomes the column effect of access_policy.

Written at commons/data/models/identity-abac/mod.ts:93

expressiontextrequired

When it applies, written in its language

Becomes the column expression of access_policy.

Written at commons/data/models/identity-abac/mod.ts:97

expressionLanguagecode of expressionLanguagerequired

The language of the condition

Becomes the column expression_language_code of access_policy.

Written at commons/data/models/identity-abac/mod.ts:98

nametextrequired

What the policy is called

Becomes the column name of access_policy.

Written at commons/data/models/identity-abac/mod.ts:91

obligationcode of obligationrequired

What must happen before an allowed action is done

Becomes the column obligation of access_policy.

Written at commons/data/models/identity-abac/mod.ts:99

policyKeytextrequired

A hash of the tenant, the name and the version, unique

Becomes the column policy_key of access_policy.

Written at commons/data/models/identity-abac/mod.ts:105

priorityintegerrequired

The order policies are evaluated and explained in; a refusal wins whatever it is

Becomes the column priority of access_policy.

Written at commons/data/models/identity-abac/mod.ts:100

resourceTypetextoptional

The kind of resource it is about

Becomes the column resource_type of access_policy.

Written at commons/data/models/identity-abac/mod.ts:96

statuscode of useStatusrequired

Whether it is applied

Becomes the column status of access_policy.

Written at commons/data/models/identity-abac/mod.ts:101

validFrominstantoptional

When it starts to apply

Becomes the column valid_from of access_policy.

Written at commons/data/models/identity-abac/mod.ts:103

validToinstantoptional

When it stops

Becomes the column valid_to of access_policy.

Written at commons/data/models/identity-abac/mod.ts:104

versionintegerrequired

Which version of the policy this is

Becomes the column version of access_policy.

Written at commons/data/models/identity-abac/mod.ts:102

Governance: relationships

permissionoptional

The permission it is about, where it is about exactly one To permission. Written at commons/data/models/identity-abac/mod.ts:112

requiresRoleoptional

A role a principal must also hold for the policy to allow To accessRole. Written at commons/data/models/identity-abac/mod.ts:111

scopePrincipaloptional

The principal or group it is scoped to To principal. Written at commons/data/models/identity-abac/mod.ts:110

tenantoptional

The tenant it is for; empty for the platform's To tenant. Written at commons/data/models/identity-abac/mod.ts:109

Logical: the table

Projects to the table access_policy with the primary key access_policy_id.

ColumnTypeNullRoleFrom
access_policy_idtextfalseattributeaccessPolicy.accessPolicyId
action_patterntextfalseattributeaccessPolicy.actionPattern
applies_totexttrueattributeaccessPolicy.appliesTo
definitiontextfalseattributeaccessPolicy.definition
effecttextfalseattributeaccessPolicy.effect
expressiontextfalseattributeaccessPolicy.expression
expression_language_codetextfalsereferenceaccessPolicy.expressionLanguage
nametextfalseattributeaccessPolicy.name
obligationtextfalseattributeaccessPolicy.obligation
permission_idtexttruereferenceaccessPolicy.permission
policy_keytextfalseattributeaccessPolicy.policyKey
priorityintegerfalseattributeaccessPolicy.priority
requires_role_access_role_role_idtexttruereferenceaccessPolicy.requiresRole
resource_typetexttrueattributeaccessPolicy.resourceType
scope_principal_principal_idtexttruereferenceaccessPolicy.scopePrincipal
statustextfalseattributeaccessPolicy.status
tenant_idtexttruereferenceaccessPolicy.tenant
valid_fromtimestamptrueattributeaccessPolicy.validFrom
valid_totimestamptrueattributeaccessPolicy.validTo
versionintegerfalseattributeaccessPolicy.version

Physical: SQL

CREATE TABLE IF NOT EXISTS "access_policy" (
    "access_policy_id" VARCHAR NOT NULL PRIMARY KEY,
    "name" VARCHAR NOT NULL,
    "definition" VARCHAR NOT NULL,
    "effect" VARCHAR NOT NULL,
    "applies_to" VARCHAR,
    "action_pattern" VARCHAR NOT NULL,
    "resource_type" VARCHAR,
    "expression" VARCHAR NOT NULL,
    "expression_language_code" VARCHAR NOT NULL,
    "obligation" VARCHAR NOT NULL,
    "priority" INTEGER NOT NULL,
    "status" VARCHAR NOT NULL,
    "version" INTEGER NOT NULL,
    "valid_from" TIMESTAMPTZ,
    "valid_to" TIMESTAMPTZ,
    "policy_key" VARCHAR NOT NULL,
    "tenant_id" VARCHAR,
    "scope_principal_principal_id" VARCHAR,
    "requires_role_access_role_role_id" VARCHAR,
    "permission_id" VARCHAR,
    CONSTRAINT "access_policy_expression_language_code_fk" FOREIGN KEY ("expression_language_code") REFERENCES "expression_language" ("code"),
    CONSTRAINT "access_policy_tenant_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "tenant" ("tenant_id"),
    CONSTRAINT "access_policy_scope_principal_principal_id_fk" FOREIGN KEY ("scope_principal_principal_id") REFERENCES "principal" ("principal_id"),
    CONSTRAINT "access_policy_requires_role_access_role_role_id_fk" FOREIGN KEY ("requires_role_access_role_role_id") REFERENCES "access_role" ("role_id"),
    CONSTRAINT "access_policy_permission_id_fk" FOREIGN KEY ("permission_id") REFERENCES "permission" ("permission_id"),
    CONSTRAINT "access_policy_policy_key_uq" UNIQUE ("policy_key"),
    CONSTRAINT "access_policy_effect_ck" CHECK ("effect" IN ('allow', 'deny')),
    CONSTRAINT "access_policy_applies_to_ck" CHECK ("applies_to" IN ('user', 'machine', 'device', 'agent', 'group')),
    CONSTRAINT "access_policy_obligation_ck" CHECK ("obligation" IN ('none', 'step_up', 'approval')),
    CONSTRAINT "access_policy_status_ck" CHECK ("status" IN ('active', 'retired'))
);

Physical: the typed table

Read and written from TypeScript with the types the model gives: import { accessPolicy } from "@intellectual-frontiers/data/sql/typed/models". Generated in commons/data/sql/typed/models/identity-abac.auto.ts: do not edit.

import { from } from "@intellectual-frontiers/data/sql/typed";
import { accessPolicy } from "@intellectual-frontiers/data/sql/typed/models";

const rows = await from(accessPolicy).select((s) => ({ accessPolicyId: s.accessPolicy.accessPolicyId, name: s.accessPolicy.name })).run(runner);

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