IF Commons GitHub

delegation

concept

One principal acting on behalf of another, for a time and for some permissions, never more than the one above it

Model identityDelegation. Written in commons/data/models/identity-delegation/mod.ts:21. Identified by delegationId.

Governance: attributes

delegationIdidentifierrequired

What identifies the delegation, made by the application

Becomes the column delegation_id of delegation.

Written at commons/data/models/identity-delegation/mod.ts:24

depthintegerrequired

How many delegations are above it: none for the first

Becomes the column depth of delegation.

Written at commons/data/models/identity-delegation/mod.ts:25

expiresAtinstantrequired

When it ends: a delegation always ends, and never after the one above it

Becomes the column expires_at of delegation.

Written at commons/data/models/identity-delegation/mod.ts:34

expressiontextoptional

An extra condition; the conditions of the delegations above it hold too, so a delegation can only add

Becomes the column expression of delegation.

Written at commons/data/models/identity-delegation/mod.ts:29

expressionLanguagecode of expressionLanguageoptional

The language of the condition

Becomes the column expression_language_code of delegation.

Written at commons/data/models/identity-delegation/mod.ts:30

maxDepthintegerrequired

How many more delegations may be added below it; less than the one above it

Becomes the column max_depth of delegation.

Written at commons/data/models/identity-delegation/mod.ts:32

purposetextrequired

What it is for

Becomes the column purpose of delegation.

Written at commons/data/models/identity-delegation/mod.ts:26

redelegablebooleanrequired

Whether the delegate may pass it on

Becomes the column redelegable of delegation.

Written at commons/data/models/identity-delegation/mod.ts:31

resourceIdtextoptional

The resource it is limited to: exact, or a prefix ending `*`

Becomes the column resource_id of delegation.

Written at commons/data/models/identity-delegation/mod.ts:28

resourceTypetextoptional

The kind of the one resource it is limited to

Becomes the column resource_type of delegation.

Written at commons/data/models/identity-delegation/mod.ts:27

revokeReasontextoptional

Why it was ended early

Becomes the column revoke_reason of delegation.

Written at commons/data/models/identity-delegation/mod.ts:37

revokedAtinstantoptional

When it was ended early

Becomes the column revoked_at of delegation.

Written at commons/data/models/identity-delegation/mod.ts:36

statuscode of delegationStatusrequired

Where it is

Becomes the column status of delegation.

Annotations: quality.transitions={"allowed":{"active":["revoked","expired"],"revoked":[],"expired":[]}}

Written at commons/data/models/identity-delegation/mod.ts:35

validFrominstantrequired

When it starts

Becomes the column valid_from of delegation.

Written at commons/data/models/identity-delegation/mod.ts:33

Governance: relationships

delegateone

Who acts on their behalf To principal. Written at commons/data/models/identity-delegation/mod.ts:43

delegatorone

Who passes on what they hold To principal. Written at commons/data/models/identity-delegation/mod.ts:42

parentoptional

The delegation it was made under, where it was made under one To delegation. Written at commons/data/models/identity-delegation/mod.ts:44

revokedByoptional

Who ended it early To principal. Written at commons/data/models/identity-delegation/mod.ts:46

rootoptional

The first delegation of the chain, where it is not itself the first To delegation. Written at commons/data/models/identity-delegation/mod.ts:45

tenantone

The tenant it is in To tenant. Written at commons/data/models/identity-delegation/mod.ts:41

Logical: the table

Projects to the table delegation with the primary key delegation_id.

ColumnTypeNullRoleFrom
delegate_principal_idtextfalsereferencedelegation.delegate
delegation_idtextfalseattributedelegation.delegationId
delegator_principal_idtextfalsereferencedelegation.delegator
depthintegerfalseattributedelegation.depth
expires_attimestampfalseattributedelegation.expiresAt
expressiontexttrueattributedelegation.expression
expression_language_codetexttruereferencedelegation.expressionLanguage
max_depthintegerfalseattributedelegation.maxDepth
parent_delegation_idtexttruereferencedelegation.parent
purposetextfalseattributedelegation.purpose
redelegablebooleanfalseattributedelegation.redelegable
resource_idtexttrueattributedelegation.resourceId
resource_typetexttrueattributedelegation.resourceType
revoke_reasontexttrueattributedelegation.revokeReason
revoked_attimestamptrueattributedelegation.revokedAt
revoked_by_principal_idtexttruereferencedelegation.revokedBy
root_delegation_idtexttruereferencedelegation.root
statustextfalseattributedelegation.status
tenant_idtextfalsereferencedelegation.tenant
valid_fromtimestampfalseattributedelegation.validFrom

Physical: SQL

CREATE TABLE IF NOT EXISTS "delegation" (
    "delegation_id" VARCHAR NOT NULL PRIMARY KEY,
    "depth" INTEGER NOT NULL,
    "purpose" VARCHAR NOT NULL,
    "resource_type" VARCHAR,
    "resource_id" VARCHAR,
    "expression" VARCHAR,
    "expression_language_code" VARCHAR,
    "redelegable" BOOLEAN NOT NULL,
    "max_depth" INTEGER NOT NULL,
    "valid_from" TIMESTAMPTZ NOT NULL,
    "expires_at" TIMESTAMPTZ NOT NULL,
    "status" VARCHAR NOT NULL,
    "revoked_at" TIMESTAMPTZ,
    "revoke_reason" VARCHAR,
    "tenant_id" VARCHAR NOT NULL,
    "delegator_principal_id" VARCHAR NOT NULL,
    "delegate_principal_id" VARCHAR NOT NULL,
    "parent_delegation_id" VARCHAR,
    "root_delegation_id" VARCHAR,
    "revoked_by_principal_id" VARCHAR,
    CONSTRAINT "delegation_expression_language_code_fk" FOREIGN KEY ("expression_language_code") REFERENCES "expression_language" ("code"),
    CONSTRAINT "delegation_tenant_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "tenant" ("tenant_id"),
    CONSTRAINT "delegation_delegator_principal_id_fk" FOREIGN KEY ("delegator_principal_id") REFERENCES "principal" ("principal_id"),
    CONSTRAINT "delegation_delegate_principal_id_fk" FOREIGN KEY ("delegate_principal_id") REFERENCES "principal" ("principal_id"),
    CONSTRAINT "delegation_parent_delegation_id_fk" FOREIGN KEY ("parent_delegation_id") REFERENCES "delegation" ("delegation_id"),
    CONSTRAINT "delegation_root_delegation_id_fk" FOREIGN KEY ("root_delegation_id") REFERENCES "delegation" ("delegation_id"),
    CONSTRAINT "delegation_revoked_by_principal_id_fk" FOREIGN KEY ("revoked_by_principal_id") REFERENCES "principal" ("principal_id"),
    CONSTRAINT "delegation_status_ck" CHECK ("status" IN ('active', 'revoked', 'expired')),
    CONSTRAINT "delegation_delegator_not_delegate_ck" CHECK ("delegator_principal_id" <> "delegate_principal_id")
);

Physical: the typed table

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

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

const rows = await from(delegation).select((s) => ({ delegationId: s.delegation.delegationId, depth: s.delegation.depth })).run(runner);

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