Skip to content

feat(auth)!: split auth, roles and claims config; strict config - #92

Merged
archlemon merged 2 commits into
mainfrom
feat/v1-auth-config
Nov 23, 2026
Merged

archlemon merged 2 commits into
mainfrom
feat/v1-auth-config

Conversation

@archlemon

@archlemon archlemon commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Pre-1.0 config and security contract changes (readiness review B1, B2, B3 and the shared bugs; pdbcore issues 76, 77, 78 and 80) for pdbr. Depends on suprbdev/pdbcore#83 (go.mod pins its commit; switched to the tag after it merges).

Config shape

auth:
  mode: jwt                     # jwt | headers | none
  jwt: {secret, secret_file, jwks_url, jwks_cache_ttl, issuer, audience, leeway, role_claim_path}
  headers: {prefix: X-Pdbr-Claim-, claims, role_claim, trusted_proxies}   # trusted_proxies required in headers mode
  mint_type: ""
roles: {switch: true, anonymous: "", default: "", allowed: []}            # empty anonymous → 401 auth_required + WWW-Authenticate
claims: {prefix: jwt.claims, json_setting: ""}                           # e.g. request.jwt.claims for PostgREST-style policies
database.statement_timeout: 25s
plugins: {disabled: [], settings: {advanced_filters: {...}, postgis: {...}, nested_mutations: {...}}}

Breaking changes (before → after)

0.x 1.0
rls.enabled roles.switch (false still verifies credentials; set auth.mode: none for no auth)
rls.anonymous_role (default anonymous) roles.anonymous (default empty → 401)
rls.default_role / rls.allowed_roles roles.default / roles.allowed
rls.role_claim auth.jwt.role_claim_path / auth.headers.role_claim
rls.claims_prefix (pdbq.claims) claims.prefix (jwt.claims)
rls.auth.* auth.mode, auth.jwt.*, auth.headers.*, auth.mint_type
PDBR_RLS_* PDBR_AUTH_* / PDBR_ROLES_* / PDBR_CLAIMS_*
kebab-case plugin names and settings snake_case (smart_comments, advanced_filters, nested_mutations, …)
unknown config keys ignored rejected with a moved-to or did-you-mean hint
database.statement_timeout 30s 25s

Other changes

  • New error code auth_required; cardinality violations (SQLSTATE class 21) are 400 instead of 500.
  • CORS exposes the non-safelisted headers pdbr sends (Content-Range, Link, X-Total-Count, ETag, Preference-Applied, Location, …) and no longer overwrites Vary.
  • pdbr request, schema dump/check and plugins list load on default config (auth.mode: none, connection role).
  • Docs: configuration.md, rls.md, errors.md, upgrading.md ("0.x → 1.0").

Tested: race, vet, lint, e2e on PostGIS 18 and 14 (-p 1), FuzzFilter/FuzzParse/FuzzSpatial/FuzzSplitEnvelope 10s each.

Identity configuration moves from rls/rls.auth to auth (mode, jwt,
headers, mint_type), roles (switch, anonymous, default, allowed) and
claims (prefix, json_setting). Headers mode requires trusted_proxies,
an empty roles.anonymous refuses unauthenticated requests with 401 and
a WWW-Authenticate challenge (new auth_required code), and the claims
prefix defaults to jwt.claims, with an optional JSON claims setting for
PostgREST-style policies.

Config loading is strict: unknown keys fail with a moved-to or
did-you-mean hint, plugin names are snake_case, plugin settings are
typed and decoded from env too, and log.format is validated. The
statement timeout defaults below the request timeout, the CLI loads on
default config, CORS exposes the response headers pdbr sends, and
cardinality violations (class 21) are client errors.

BREAKING CHANGE: rls.* keys, kebab-case plugin names and the
pdbq.claims prefix are replaced; see docs/upgrading.md.
@archlemon
archlemon merged commit 39e7e6f into main Nov 23, 2026
4 checks passed
@archlemon
archlemon deleted the feat/v1-auth-config branch November 23, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant