accessSourcefunctionfunction accessSource(settings?: AccessSettings): StatementSourceThe source of row-level security and grants.
| Parameter | What it is |
|---|---|
settings | what a project says of access |
Returns: a statement source
Access (commons data 0009-sql-features FR-008 to FR-010): what governance says of who may see what becomes what the engine enforces. A column that carries security.scope makes its table's rows visible only where the column equals the setting of the scope; a concept that carries security.access grants its read roles SELECT and its write roles INSERT, UPDATE and DELETE, and, where the table is scoped, gives each of them a policy for what they may do. A dialect without the feature gets nothing, and the annotation stays in the governance tables.
The policy reads current_setting('<prefix>.<scope>', true) and compares it with the column as text, which is PostgreSQL's way; no other dialect has row-security yet.
accessSourcefunctionfunction accessSource(settings?: AccessSettings): StatementSourceThe source of row-level security and grants.
| Parameter | What it is |
|---|---|
settings | what a project says of access |
Returns: a statement source
governedTablesconstno test imports itconst governedTables: (tables: readonly Table[]) => readonly Table[]The tables of a schema that carry a scope or an access, which an access source acts on.
grantOffunctionfunction grantOf(values: "*" | readonly string[]): stringWhat a scope of a set reaches: the tenants, or every one (*). A value with a comma in it cannot be listed, since the comma is what separates them.
scopeStatementconstconst scopeStatement: (key: string, name: string, value: string, prefix?: string, local?: boolean) => stringThe statement that sets a sealed scope for the transaction (or, where local is false, the session) that runs it.
sealedScopeconstconst sealedScope: (key: string, name: string, value: string) => stringThe value to give a sealed scope setting: the value and its mark, made by the issuer that holds the key.
AccessSettingsinterfaceno test imports itinterface AccessSettingsWhat a project says of access; what is not said is the default.
| Member | Type | What it is |
|---|---|---|
unsupported? | "carry" | "error" | What to do where the dialect lacks the feature: carry writes nothing and leaves the annotation to the governance tables (the default), error returns an error value. |
settingPrefix? | string | The prefix of the settings a policy reads; app by default. |
viewsSchema? | string | Set where the tables are wrapped by views (0014-sql-protected-access): the rights are then the views' to grant, so none is granted here, and a table with a scope has one policy that names no role, forced on its owner. |
seal? | { readonly key: string; readonly unlock?: string | undefined; } | Seals the scope (0009-sql-features FR-019, PostgreSQL): a policy trusts the setting of a scope only where it carries the mark that only a holder of key can make, so that a session of the application, or a statement injected into it, cannot set the scope to another tenant's. The key is kept in a table that no role but the deployer's can read; the issuer of the scope (the service that has authenticated the caller) makes the mark with sealedScope. Row security is forced on the tables' owners and a guard refuses to disable it, or drop a policy or a table of it unless the session holds the secret whose hash is unlock. |
reach? | "exact" | "set" | How far a scope reaches (0009-sql-features FR-020, PostgreSQL). exact, the default, shows a row where its scope column equals the setting. set reads the setting as a list of values, separated by commas (acme,acme-eu), and shows a row where its column is one of them: a reseller reaches the tenants beneath it, a support role the few it is asked to help, and the issuer of the scope (which has authenticated the caller and knows the hierarchy) decides which. With wildcard, the value * reaches every row, for a platform operator. A reach is only as trustworthy as the scope: seal it. |
wildcard? | boolean | With reach: "set", whether the value * reaches every row; off by default. |