IF Commons GitHub

roleAssignment

concept

A role granted to a principal of any kind, in a tenant, perhaps for one resource and for a time

Model identityAccess. Written in commons/data/models/identity-access/concepts.ts:95. Identified by roleAssignmentId.

Governance: attributes

assignmentKeytextrequired

A hash of the principal, the role, the tenant and the resource, unique, so that a grant is not made twice where the resource is empty

Becomes the column assignment_key of role_assignment.

Written at commons/data/models/identity-access/concepts.ts:107

reasontextoptional

Why it was granted

Becomes the column reason of role_assignment.

Written at commons/data/models/identity-access/concepts.ts:103

resourceIdtextoptional

The one resource the grant is limited to, where it is

Becomes the column resource_id of role_assignment.

Written at commons/data/models/identity-access/concepts.ts:100

resourceTypetextoptional

The kind of the one resource the grant is limited to, where it is

Becomes the column resource_type of role_assignment.

Written at commons/data/models/identity-access/concepts.ts:99

revokedAtinstantoptional

When it was ended early

Becomes the column revoked_at of role_assignment.

Written at commons/data/models/identity-access/concepts.ts:105

roleAssignmentIdidentifierrequired

What identifies the grant, made by the application

Becomes the column role_assignment_id of role_assignment.

Written at commons/data/models/identity-access/concepts.ts:98

statuscode of assignmentStatusrequired

Where the grant is

Becomes the column status of role_assignment.

Written at commons/data/models/identity-access/concepts.ts:104

validFrominstantrequired

When the grant starts

Becomes the column valid_from of role_assignment.

Written at commons/data/models/identity-access/concepts.ts:101

validToinstantoptional

When the grant ends, where it does

Becomes the column valid_to of role_assignment.

Written at commons/data/models/identity-access/concepts.ts:102

viacode of assignmentViarequired

How it came to be

Becomes the column via of role_assignment.

Written at commons/data/models/identity-access/concepts.ts:106

Governance: relationships

grantedByone

Who granted it To principal. Written at commons/data/models/identity-access/concepts.ts:114

principalone

Who holds the role To principal. Written at commons/data/models/identity-access/concepts.ts:111

roleone

The role To accessRole. Written at commons/data/models/identity-access/concepts.ts:112

tenantone

The tenant the grant is in To tenant. Written at commons/data/models/identity-access/concepts.ts:113

Logical: the table

Projects to the table role_assignment with the primary key role_assignment_id.

ColumnTypeNullRoleFrom
assignment_keytextfalseattributeroleAssignment.assignmentKey
granted_by_principal_idtextfalsereferenceroleAssignment.grantedBy
principal_idtextfalsereferenceroleAssignment.principal
reasontexttrueattributeroleAssignment.reason
resource_idtexttrueattributeroleAssignment.resourceId
resource_typetexttrueattributeroleAssignment.resourceType
revoked_attimestamptrueattributeroleAssignment.revokedAt
role_access_role_role_idtextfalsereferenceroleAssignment.role
role_assignment_idtextfalseattributeroleAssignment.roleAssignmentId
statustextfalseattributeroleAssignment.status
tenant_idtextfalsereferenceroleAssignment.tenant
valid_fromtimestampfalseattributeroleAssignment.validFrom
valid_totimestamptrueattributeroleAssignment.validTo
viatextfalseattributeroleAssignment.via

Physical: SQL

CREATE TABLE IF NOT EXISTS "role_assignment" (
    "role_assignment_id" VARCHAR NOT NULL PRIMARY KEY,
    "resource_type" VARCHAR,
    "resource_id" VARCHAR,
    "valid_from" TIMESTAMPTZ NOT NULL,
    "valid_to" TIMESTAMPTZ,
    "reason" VARCHAR,
    "status" VARCHAR NOT NULL,
    "revoked_at" TIMESTAMPTZ,
    "via" VARCHAR NOT NULL,
    "assignment_key" VARCHAR NOT NULL,
    "principal_id" VARCHAR NOT NULL,
    "role_access_role_role_id" VARCHAR NOT NULL,
    "tenant_id" VARCHAR NOT NULL,
    "granted_by_principal_id" VARCHAR NOT NULL,
    CONSTRAINT "role_assignment_principal_id_fk" FOREIGN KEY ("principal_id") REFERENCES "principal" ("principal_id"),
    CONSTRAINT "role_assignment_role_access_role_role_id_fk" FOREIGN KEY ("role_access_role_role_id") REFERENCES "access_role" ("role_id"),
    CONSTRAINT "role_assignment_tenant_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "tenant" ("tenant_id"),
    CONSTRAINT "role_assignment_granted_by_principal_id_fk" FOREIGN KEY ("granted_by_principal_id") REFERENCES "principal" ("principal_id"),
    CONSTRAINT "role_assignment_assignment_key_uq" UNIQUE ("assignment_key"),
    CONSTRAINT "role_assignment_status_ck" CHECK ("status" IN ('active', 'revoked', 'expired')),
    CONSTRAINT "role_assignment_via_ck" CHECK ("via" IN ('direct', 'privileged_grant', 'directory', 'invitation'))
);

Physical: the typed table

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

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

const rows = await from(roleAssignment).select((s) => ({ roleAssignmentId: s.roleAssignment.roleAssignmentId, resourceType: s.roleAssignment.resourceType })).run(runner);

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