8000 Field-level (column) permissions in the allowlist JSON · Issue #3 · simon-inkie/inkie-pg-read · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Field-level (column) permissions in the allowlist JSON #3

Closed

Description

@simon-inkie

Summary

The per-agent / per-project allowlist (.pgr-agent.json) only controls access by table. Add optional field (column) level permissions in the same file, so a caller can be allowed a table but only some of its columns.

Why

Today the only ways to hide a sensitive column are to create a database view that leaves it out and allow the view, or to grant the database role only some columns, which applies to every caller of that role rather than one agent. A per-caller column allowlist in the config would make "this agent may read clients but not the email column" a one-line change.

Proposal

Keep the existing shape working and allow an object form for a table:

{
  "pgr": {
    "tables": {
      "allow": [
        "interviews",
        { "table": "memberships", "columns": ["id", "created_at", "role", "client_id"] }
      ]
    }
  }
}
  • A plain string entry keeps today's meaning (all columns).
  • With columns set, queries that reference any other column of that table (including select *, which would expand to all columns) are rejected before they run, with a denial message that names the column and the config file.
  • Default-deny stays: a column not listed is denied.

Things to decide

  • Parsing: the current guard works on table names. Column checks need the guard to resolve which table each column belongs to, including aliases, joins, CTEs and subqueries. A conservative first version could reject select * and unqualified columns on any table that has a column list.
  • Expressions that read a restricted column indirectly (functions over a whole row, to_jsonb(t)) need rejecting.
  • Config validation: unknown shapes should fail loudly, not silently allow.
  • Tests: aliases, joins, CTEs, select *, row-to-json, and the string-entry backward compatibility.

Not in scope

Row-level filtering (the role bypasses RLS by design; a per-caller tenant filter is a separate question).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0