Tier-4
Merged
HU
4mo ago+13338+13338+01234567890123456789012345678901234567890123456789-5852-5852-0123456789012345678901234567890123456789
- Added support for JWT authentication, allowing users to exchange API keys for JWTs via the new
/auth/tokenendpoint. - Introduced API key management with routes for listing and creating API keys, enhancing security and user control.
- Updated the OpenAPI specification to reflect new authentication methods and security schemes.
- Enhanced the principal resolution logic to support JWTs and API keys, improving authorization handling across the application.
- Added tests to ensure proper functionality of the new authentication features and their integration with existing components.
Summary by cubic
Adds JWT auth with an /auth/token exchange and hashed API keys, and updates principal resolution to accept JWTs or API keys. Also adds DO-backed rate limiting, KV caching for session lists, structured logging, and SPA upgrades (Owner switcher, API key UI, PWA/offline, i18n, scorecard export).
-
New Features
- Auth:
POST /auth/token(HS256, 1h TTL), API key list/create/revoke (hashed in DB), updated OpenAPI, and JWT/API key resolution across routes; web usesAuthProvider+OwnerSwitcherwith demo keys still supported. - Scale:
RateLimiterDurable Object per IP, KV cache forGET /sessions(60s KV / 15s HTTP,X-Cache), structured JSON logs withX-Trace-Id, and deep readinessGET /health?deep=1. - DX/Docs/Tests: OpenAPI exported to
/openapi.jsonwith Redoc page, contract + unit + visual tests added, andwrangler@4upgrade. - UX: PWA via
vite-plugin-pwawith offline read-only cache (React Query persistence),react-i18next(en), scorecard export, improved file input, and optional analytics.
- Auth:
-
Migration
- Run DB migrations to create
api_keys(e.g.npm run db:prepare). - Set
OCHE_JWT_SECRET(Wrangler secret) and sync.dev.vars; keep demo keys for local use. - Bind
RATE_LIMITERDO andCACHEKV inapps/api/wrangler.toml(apply migrations). - Rebuild web (OpenAPI export runs in
apps/webbuild).
- Run DB migrations to create