Skip to content

v0.333.0 — API keys for programmatic access

Choose a tag to compare

@budgets-au budgets-au released this 13 Aug 22:07
· 38 commits to main since this release

Container

ghcr.io/budgets-au/budgets:0.333.0
ghcr.io/budgets-au/budgets:latest

Added

  • API keys — long-lived bearer tokens for programmatic access. Admin operators can now mint, list, and revoke API keys under Settings → Security → API keys. Present via `Authorization: Bearer bk_…` on any API call; the auth guard accepts either a session cookie OR a valid bearer.
    • Format: `bk_` prefix + 32 bytes of URL-safe base64 (43 chars). The prefix makes leaks eyeballable in grep and CI logs.
    • Storage: only the SHA-256 hex digest lives in the DB. The plaintext is shown ONCE at creation and never round-tripped again — an emerald banner in the panel highlights the value with a copy button, then dismisses.
    • Role: keys default to admin scope.
    • Revoke: hard delete of the row — a leaked key stops working immediately.
    • `lastUsedAt` bumps on every authenticated call, so operators can spot stale keys.
    • Guard behaviour: when a Bearer is present, guard does NOT fall back to session auth — a stale cookie can't override a freshly-revoked key on the same request.
  • Migration 0018 — `api_keys` table. Applied automatically at first unlock.

Endpoints

  • `POST /api/settings/api-keys` — create (returns plaintext once).
  • `GET /api/settings/api-keys` — list metadata (no plaintext).
  • `DELETE /api/settings/api-keys/[id]` — revoke.

Usage

curl -H "Authorization: Bearer bk_..." https://your-host/api/accounts

Verify

  • tsc clean, `pnpm build` clean, 741/751 unit pass (+13 vs 0.332), pages-smoke + proxy-auth 16/16 green.

Upgrade

Pull `ghcr.io/budgets-au/budgets:0.333.0`. The 0018 migration runs on first unlock. Existing user sessions unchanged.