Files
FlowReader/migrations/007_perf_reading.down.sql
Antigravity AgentandClaude Opus 5.5 03e57e4308 fix(backend): harden security and speed up feeds and article API
Security:
- WebSocket events are routed to their owner only (no cross-user leak);
  hub close is idempotent (fixes double-close panic), adds ping/pong and
  write deadlines.
- Session tokens stored as SHA-256 (migration 008 keeps sessions valid);
  single-query auth middleware puts the user in the request context.
- Client IP only trusts X-Forwarded-For from TRUSTED_PROXIES; rate limiter
  map is bounded; per-user limit on AI summaries.
- Argon2id at OWASP minimum with a concurrency cap; constant-time login
  for unknown emails; atomic first-admin bootstrap; REGISTRATION_ENABLED.
- CSP/HSTS/COOP headers, same-origin guard on mutations, body size limits,
  wider SSRF denylist, bounded feed/page/AI response reads, generic errors.
- Upgrade chi, pgx, x/net, x/text, x/crypto (known CVEs); commit go.sum.

Performance:
- List endpoints return a plain-text excerpt and reading time instead of
  full HTML; content is sanitized once at ingest (legacy rows backfilled).
- Keyset pagination on (sort_at, id) with matching partial indexes;
  redundant indexes dropped (migration 007).
- Fetcher: bounded worker pool, conditional GET (ETag/Last-Modified),
  exponential backoff, dedupe before insert, column-safe truncation,
  retention-aware ingest, per-user refresh coalescing.
- Read/favorite/read-all are single ownership-scoped statements.
- gzip compression, immutable caching for hashed assets, path-safe SPA
  handler, server timeouts; expired sessions purged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 07:34:08 +02:00

27 lines
1.3 KiB
SQL

DROP INDEX IF EXISTS idx_feeds_next_fetch;
ALTER TABLE feeds DROP COLUMN IF EXISTS next_fetch_at;
ALTER TABLE feeds DROP COLUMN IF EXISTS error_count;
ALTER TABLE feeds DROP COLUMN IF EXISTS last_modified;
ALTER TABLE feeds DROP COLUMN IF EXISTS etag;
CREATE INDEX IF NOT EXISTS idx_feeds_user_id ON feeds(user_id);
CREATE INDEX IF NOT EXISTS idx_sessions_token ON sessions(token);
CREATE INDEX IF NOT EXISTS idx_users_email ON users(email);
CREATE INDEX IF NOT EXISTS idx_articles_is_favorite ON articles(feed_id, is_favorite);
CREATE INDEX IF NOT EXISTS idx_articles_is_read ON articles(feed_id, is_read);
CREATE INDEX IF NOT EXISTS idx_articles_published_at ON articles(published_at DESC);
CREATE INDEX IF NOT EXISTS idx_articles_feed_id ON articles(feed_id);
DROP INDEX IF EXISTS idx_articles_backfill;
DROP INDEX IF EXISTS idx_articles_cleanup;
DROP INDEX IF EXISTS idx_articles_unread_feed;
DROP INDEX IF EXISTS idx_articles_fav_sort;
DROP INDEX IF EXISTS idx_articles_unread_sort;
DROP INDEX IF EXISTS idx_articles_sort;
DROP INDEX IF EXISTS idx_articles_feed_unread_sort;
DROP INDEX IF EXISTS idx_articles_feed_sort;
ALTER TABLE articles DROP COLUMN IF EXISTS sort_at;
ALTER TABLE articles DROP COLUMN IF EXISTS word_count;
ALTER TABLE articles DROP COLUMN IF EXISTS excerpt;