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: attributesA 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
Why it was granted
Becomes the column reason of role_assignment.
Written at commons/data/models/identity-access/concepts.ts:103
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
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
When it was ended early
Becomes the column revoked_at of role_assignment.
Written at commons/data/models/identity-access/concepts.ts:105
roleAssignmentIdidentifier required 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 assignmentStatus required Where the grant is
Becomes the column status of role_assignment.
Written at commons/data/models/identity-access/concepts.ts:104
When the grant starts
Becomes the column valid_from of role_assignment.
Written at commons/data/models/identity-access/concepts.ts:101
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 assignmentVia required How it came to be
Becomes the column via of role_assignment.
Written at commons/data/models/identity-access/concepts.ts:106
# Governance: relationships# Logical: the tableProjects to the table role_assignment with the primary key role_assignment_id.
# Physical: SQLduckdb postgres sqlite
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' ))
);CREATE TABLE IF NOT EXISTS "role_assignment" (
"role_assignment_id" TEXT NOT NULL PRIMARY KEY ,
"resource_type" TEXT ,
"resource_id" TEXT ,
"valid_from" TIMESTAMPTZ NOT NULL ,
"valid_to" TIMESTAMPTZ,
"reason" TEXT ,
"status" TEXT NOT NULL ,
"revoked_at" TIMESTAMPTZ,
"via" TEXT NOT NULL ,
"assignment_key" TEXT NOT NULL ,
"principal_id" TEXT NOT NULL ,
"role_access_role_role_id" TEXT NOT NULL ,
"tenant_id" TEXT NOT NULL ,
"granted_by_principal_id" TEXT 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' ))
);CREATE TABLE IF NOT EXISTS "role_assignment" (
"role_assignment_id" TEXT NOT NULL PRIMARY KEY ,
"resource_type" TEXT ,
"resource_id" TEXT ,
"valid_from" TEXT NOT NULL ,
"valid_to" TEXT ,
"reason" TEXT ,
"status" TEXT NOT NULL ,
"revoked_at" TEXT ,
"via" TEXT NOT NULL ,
"assignment_key" TEXT NOT NULL ,
"principal_id" TEXT NOT NULL ,
"role_access_role_role_id" TEXT NOT NULL ,
"tenant_id" TEXT NOT NULL ,
"granted_by_principal_id" TEXT 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 tableRead 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);