Skip to content

Policy input

Each statement is prepared, not executed, and the policy receives what DuckDB says it does:

{
"user": "analyst",
"roles": ["analyst"],
"sql": "SELECT ...",
"statement_type": "SELECT",
"database": "sales",
"tables": ["sales.main.orders"],
"targets": [],
"functions": ["range"],
"databases": ["sales"],
"resolved": true
}
Field
user user name, API key name or OIDC user claim
roles roles from the users file, token or identities
sql statement text
statement_type SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, EXPLAIN, PRAGMA…
database catalog for unqualified names
tables base tables read, views expanded
targets objects written, created or dropped
functions table functions used as sources
databases catalogs touched by tables and targets
resolved false when tables or targets could not be fully determined
hidden_remote_scans lake scans behind views or macros
identity, actor only on delegated requests
caller only when a shared key sends X-Curral-Caller-Context

The allow decision covers /v1/query. Writes to semantic documents go through a separate decision with its own input; see below.

  • tables come from DuckDB’s unoptimized logical plan, so joins, USING, CTEs, subqueries and views cannot hide a read.
  • targets come from a tokenizer, because DuckDB does not expose them. Secrets appear as secret:<name> and schemas as db.schema.*.
  • functions such as read_parquet bypass table grants; allow them explicitly.
  • EXPLAIN ANALYZE <stmt> is authorized as <stmt>, since it executes.
  • External catalogs (Iceberg): for SELECT, tables come from the parser’s syntax tree, respecting CTE scope. Other statements reading these catalogs arrive with resolved: false.

Deny, unless the user is fully trusted. It is false when:

  • the target of a write cannot be determined;
  • the statement uses lexical constructs the tokenizer does not model exactly like DuckDB ($$...$$, nested comments, E'...');
  • the statement type has no explicit handling (CALL, VACUUM, COPY DATABASE…);
  • lake tables are read through a view or macro (hidden_remote_scans > 0).

When a trusted service queries on behalf of a user, the input describes the effective identity, and adds who asserted it:

{
"user": "portal:tenant-a:user:42",
"roles": [],
"identity": {"subject": "portal:tenant-a:user:42", "kind": "user", "tenant": "tenant-a"},
"actor": {"name": "portal", "auth_method": "api_key", "attributes": {"tenant": "tenant-a"}},
"statement_type": "SELECT",
"...": "..."
}
Field
user the effective subject
roles roles identities: maps to that subject; never the key’s
identity the whole execution context, as the service sent it
actor {name, auth_method, attributes} of the delegating key
caller the audit-only context a shared key sent with X-Curral-Caller-Context; the request still runs as the key

Delegated requests are refused unless the statement is a SELECT, whatever the policy decides. Tie every rule that allows them to input.actor.

With --docs-dir, POST, PUT, PATCH and DELETE on /v1/docs are decided by --policy-docs-query (default data.curral.docs_allow), which is undefined, and so denies, until the policy defines it. Reads and search require authentication; --docs-scope schema also checks the caller’s query permissions.

{
"action": "update",
"user": "poet",
"roles": ["poet"],
"doc_id": "019a2f1c3a4b9f2e18c4d7a6b05",
"author": "admin",
"doc": {"title": "Monthly revenue", "author": "admin", "tables": ["lake.analytics.monthly_revenue"], "schemas": []},
"current": {"title": "Revenue", "author": "admin", "tables": ["lake.analytics.monthly_revenue"], "schemas": []}
}
Field
action create, update (PUT and PATCH) or delete
user, roles the caller
doc_id the document id, generated by the server on create
author who created the document; absent on create
doc {title, author, tables, schemas} as the document will be saved; absent on delete
current the same fields as the document is now; absent on create
identity, actor effective identity and delegating key for document writes with docs_write: true

A rule scoped to some tables must check both doc and current, or an update could take over a document about other tables by rewriting its tables.