accessPolicyIdidentifierrequiredWhat 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
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.
accessPolicyIdidentifierrequiredWhat 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
actionPatterntextrequiredThe 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 principalKindoptionalThe 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
definitiontextrequiredWhat the policy is for
Becomes the column definition of access_policy.
Written at commons/data/models/identity-abac/mod.ts:88
effectcode of policyEffectrequiredWhat it decides
Becomes the column effect of access_policy.
Written at commons/data/models/identity-abac/mod.ts:93
expressiontextrequiredWhen 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 expressionLanguagerequiredThe language of the condition
Becomes the column expression_language_code of access_policy.
Written at commons/data/models/identity-abac/mod.ts:98
nametextrequiredWhat the policy is called
Becomes the column name of access_policy.
Written at commons/data/models/identity-abac/mod.ts:91
obligationcode of obligationrequiredWhat 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
policyKeytextrequiredA 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
priorityintegerrequiredThe 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
resourceTypetextoptionalThe 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 useStatusrequiredWhether it is applied
Becomes the column status of access_policy.
Written at commons/data/models/identity-abac/mod.ts:101
validFrominstantoptionalWhen it starts to apply
Becomes the column valid_from of access_policy.
Written at commons/data/models/identity-abac/mod.ts:103
validToinstantoptionalWhen it stops
Becomes the column valid_to of access_policy.
Written at commons/data/models/identity-abac/mod.ts:104
versionintegerrequiredWhich version of the policy this is
Becomes the column version of access_policy.
Written at commons/data/models/identity-abac/mod.ts:102
permissionoptionalThe permission it is about, where it is about exactly one To permission. Written at commons/data/models/identity-abac/mod.ts:112
requiresRoleoptionalA role a principal must also hold for the policy to allow To accessRole. Written at commons/data/models/identity-abac/mod.ts:111
scopePrincipaloptionalThe principal or group it is scoped to To principal. Written at commons/data/models/identity-abac/mod.ts:110
tenantoptionalThe tenant it is for; empty for the platform's To tenant. Written at commons/data/models/identity-abac/mod.ts:109
Projects to the table access_policy with the primary key access_policy_id.
| Column | Type | Null | Role | From |
|---|---|---|---|---|
access_policy_id | text | false | attribute | accessPolicy.accessPolicyId |
action_pattern | text | false | attribute | accessPolicy.actionPattern |
applies_to | text | true | attribute | accessPolicy.appliesTo |
definition | text | false | attribute | accessPolicy.definition |
effect | text | false | attribute | accessPolicy.effect |
expression | text | false | attribute | accessPolicy.expression |
expression_language_code | text | false | reference | accessPolicy.expressionLanguage |
name | text | false | attribute | accessPolicy.name |
obligation | text | false | attribute | accessPolicy.obligation |
permission_id | text | true | reference | accessPolicy.permission |
policy_key | text | false | attribute | accessPolicy.policyKey |
priority | integer | false | attribute | accessPolicy.priority |
requires_role_access_role_role_id | text | true | reference | accessPolicy.requiresRole |
resource_type | text | true | attribute | accessPolicy.resourceType |
scope_principal_principal_id | text | true | reference | accessPolicy.scopePrincipal |
status | text | false | attribute | accessPolicy.status |
tenant_id | text | true | reference | accessPolicy.tenant |
valid_from | timestamp | true | attribute | accessPolicy.validFrom |
valid_to | timestamp | true | attribute | accessPolicy.validTo |
version | integer | false | attribute | accessPolicy.version |
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'))
);CREATE TABLE IF NOT EXISTS "access_policy" (
"access_policy_id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"definition" TEXT NOT NULL,
"effect" TEXT NOT NULL,
"applies_to" TEXT,
"action_pattern" TEXT NOT NULL,
"resource_type" TEXT,
"expression" TEXT NOT NULL,
"expression_language_code" TEXT NOT NULL,
"obligation" TEXT NOT NULL,
"priority" INTEGER NOT NULL,
"status" TEXT NOT NULL,
"version" INTEGER NOT NULL,
"valid_from" TIMESTAMPTZ,
"valid_to" TIMESTAMPTZ,
"policy_key" TEXT NOT NULL,
"tenant_id" TEXT,
"scope_principal_principal_id" TEXT,
"requires_role_access_role_role_id" TEXT,
"permission_id" TEXT,
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'))
);CREATE TABLE IF NOT EXISTS "access_policy" (
"access_policy_id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"definition" TEXT NOT NULL,
"effect" TEXT NOT NULL,
"applies_to" TEXT,
"action_pattern" TEXT NOT NULL,
"resource_type" TEXT,
"expression" TEXT NOT NULL,
"expression_language_code" TEXT NOT NULL,
"obligation" TEXT NOT NULL,
"priority" INTEGER NOT NULL,
"status" TEXT NOT NULL,
"version" INTEGER NOT NULL,
"valid_from" TEXT,
"valid_to" TEXT,
"policy_key" TEXT NOT NULL,
"tenant_id" TEXT,
"scope_principal_principal_id" TEXT,
"requires_role_access_role_role_id" TEXT,
"permission_id" TEXT,
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'))
);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);