Files
Andrew S Erwin e6ab778bd5 Add personal API keys, superbrain-mcp, and fix Markdown prose styling
API keys & MCP (the mcpserver-link prerequisite from STRATEGY.md):
- ApiKey table (migration 017 + schema.sql): hash-only storage of personal
  "sb_..." Bearer credentials, unique keyHash, owner cascade.
- internal/auth/apikeys.go + AuthMiddleware fork: keys resolve before the
  assertion/cookie channels; gated on the mcp-core connector at issuance
  AND at every use (downgrade 403s); independent of tokenVersion so "sign
  out everywhere" never breaks a gateway link; view-as stays browser-only.
- /api/keys GET/POST/DELETE: plaintext shown exactly once, 10-key cap under
  the user lock, owner-scoped revocation; Settings -> API Keys tab.
- mcp/: superbrain-mcp, a pip-installable stdio MCP server (listmonk-mcp
  pattern) with bookmarks/tags/pages tools, version-safe updates; the
  federated gateway spawns it via config_mcpserver_superbrain() in
  deploy/federated/lib-superbrain.sh (mints the gateway key in-db, points
  it at http://superbrain-app:8080). STRATEGY.md records the remaining
  suite-side registry work.
- Tests: TestAPIKeys (plan gate, cap, revocation, tokenVersion semantics,
  downgrade-at-use); full DB-backed suite, db-converge, live MCP-client
  smoke all pass.

Markdown (Gitea issue #3): add @tailwindcss/typography and enable it in
tailwind.config.ts. The prose wrapper was a no-op without it, so Tailwind
Preflight flattened headings/blockquotes to body text while bold/italic
survived - exactly the reported symptom. Verified in the built CSS.

Gitea: #2 and #3 closed with reference notes; #1 stays open pending the
Superpanel core-AI walkthrough.
2026-11-02 14:27:58 -06:00

28 lines
1.2 KiB
SQL

-- 017_api_keys.sql — personal API keys for machine clients (MCP).
--
-- Additive and idempotent; schema.sql carries the identical table, so this
-- is a structural no-op on a fresh database (db-converge proves both paths
-- land the same).
--
-- Long-lived Bearer credentials ("sb_...") for non-browser clients — the
-- superbrain-mcp server the federated mcpserver gateway spawns, or any REST
-- client. Only the SHA-256 hash is stored; the plaintext is shown exactly
-- once at creation. Revocation is deletion of the row (there is no soft
-- state); keys are deliberately independent of User.tokenVersion — "sign
-- out everywhere" targets browser sessions, machine credentials must be
-- revoked explicitly so a gateway link survives a password change.
-- Issuance AND use are gated on the tenant's mcp-core connector
-- (entitlements catalog: core plan), so a downgrade stops existing keys.
CREATE TABLE IF NOT EXISTS "ApiKey" (
id text PRIMARY KEY,
"ownerId" text NOT NULL REFERENCES "User"(id) ON DELETE CASCADE,
name text NOT NULL,
prefix text NOT NULL,
"keyHash" text NOT NULL UNIQUE,
"lastUsedAt" timestamptz,
"createdAt" timestamptz NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS "ApiKey_ownerId_idx" ON "ApiKey"("ownerId");