Repository navigation
pgokf 0.1.16
Deny-by-default tenancy, on demand. The new durable policy key
require_tenant (default false) makes a session that has not set
pgokf.tenant see nothing and refuse to ingest, instead of the see-all
behavior every earlier release had. Nothing changes until an administrator
turns it on; ALTER EXTENSION pgokf UPDATE TO '0.1.16' adds one column and
rewrites the thirteen tenant-isolation policies in place.
Added
require_tenantpolicy key and the reader-level
pgokf.tenant_required()function every row-level-security policy consults
(as an uncorrelated sub-select: one evaluation per statement, never a
per-row call). With the policy on, an unscoped session sees no rows through
the policies and every reader built on them, theSECURITY DEFINERreaders
apply the same rule (health()counts,list_sync_log,list_sync_changes,
list_access_log, and the ParadeDBbm25_hitspath come back empty;
get_concept_sourceraises the same not-found22023a foreign tenant
gets), and the ingestion tier, the bundle-addressed writers and exports, and
purge_retiredrefuse it with SQLSTATE42501.set_config/reset_confignever need a
tenant, so the policy can always be turned off again.health()gains
tenant_required. The function is executable by any role withUSAGEon
schemapgokf, because the policies depend on it.- Companions:
pgokf-ingestaccepts--tenant/OKF_TENANTlike
pgokf-embedandpgokf-mcp; all three apply it through one shared
pgokf-pgconnhelper. The compose stack passesOKF_EMBED_TENANTand
OKF_INGEST_TENANTthrough (next to the existingOKF_MCP_TENANT).
Changed
schedule_refreshpins the bundle's tenant into the pg_cron job command
(set_config('pgokf.tenant', ...)beforerefresh_bundle), so the cron
worker's own, tenant-less session satisfies the tenant rules. Jobs
scheduled by earlier releases run the bare call; re-schedule them
(schedule_refreshupdates a job in place) before turningrequire_tenant
on, or pin the job role's tenant withALTER ROLE ... SET pgokf.tenant.- The write-side tenant rule (
enforce_bundle_tenant) now also refuses an
unscoped session when a tenant is required, with a distinct42501message
naming the fix, rather than the unknown-bundle22023used for cross-tenant
ids.
Images: ghcr.io/logicocean/pgokf:0.1.16-pg{15,16,17,18} and ghcr.io/logicocean/pgokf-companions:0.1.16 (linux/amd64 + linux/arm64). Homebrew: brew tap logicocean/pgokf && brew install pgokf.