Commit Graph
26 Commits
Author SHA1 Message Date
kyleandClaude Opus 4.6 f1b67b9909 Add GetNotebook RPC for pulling complete notebook data
New RPC returns notebook metadata, all pages, and all strokes for
a given server-side notebook ID. Enables desktop and other clients
to download notebooks from the server (pull sync).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 15:06:20 -07:00
kyleandClaude Opus 4.6 651eabe995 Add notebook delete, fix button styling, rename Share button
- Add delete notebook handler with ownership check and CASCADE delete
- Rename "Create Share Link" to "Share"
- Fix action button heights: use inline-flex + align-items for
  consistent sizing across <a> and <button> elements

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 09:43:57 -07:00
kyleandClaude Opus 4.6 aeb12d9f50 Add rendering routes and share UI to web server
The web UI was linking to /v1/ REST API paths that aren't served
through nginx. Added SVG/JPG/PDF rendering and share link endpoints
directly to the web server so everything works through port 443.

- Add render.go with SVG, JPG, PDF handlers for auth and share paths
- Register render routes and share management routes in web server
- Update template links from /v1/... to /notebooks/... paths
- Add share link creation, display, and revocation to notebook view

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 09:22:07 -07:00
kyleandClaude Opus 4.6 ab2884a8e9 Fix gRPC auth metadata keys, allow TLS 1.2 for Android clients
- Read x-engpad-username/x-engpad-password from gRPC metadata
  (matching what the Android client sends)
- Allow TLS 1.2 on gRPC port — Android's BoringSSL/OkHttp transport
  does not negotiate TLS 1.3 without Conscrypt

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 09:08:24 -07:00
kyleandClaude Opus 4.6 691301dade Update docs for Docker-on-deimos deployment, add grpc_plain_addr option
- ARCHITECTURE.md: document nginx + direct gRPC topology, add
  grpc_plain_addr config, update cert filenames to Let's Encrypt
  convention, add passwd to CLI table
- RUNBOOK.md: replace systemctl/journalctl with docker commands,
  fix cert path references, improve sync troubleshooting steps
- Example config: update cert paths, document grpc_plain_addr option
- grpcserver: add optional plaintext gRPC listener for reverse proxy
- config: add GRPCPlainAddr field

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 08:58:01 -07:00
kyleandClaude Opus 4.6 2185bbe563 Add passwd command, fix template rendering, update deployment docs
- Add `passwd` CLI command to reset user passwords
- Fix web UI templates: parse each page template with layout so blocks
  render correctly (was outputting empty pages)
- Add login error logging for debugging auth failures
- Update README with deploy workflow and container management commands
- Update RUNBOOK for Docker-on-deimos deployment (replaces systemd refs)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 08:27:31 -07:00
kyleandClaude Opus 4.6 da148a577d Add docker-compose, RUNBOOK.md, and docker Makefile target
- docker-compose.yml: single service with data volume, ports 8443/9443/8080
- RUNBOOK.md: health checks, common operations (start/stop/backup/init),
  FIDO2 key registration, incident procedures (won't start, DB corruption,
  cert expiry, disk full, sync failures), escalation path
- Makefile: added docker target

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v0.1.0
2026-03-24 21:36:27 -07:00
kyleandClaude Opus 4.6 710fcfcd34 Complete WebAuthn web handlers and download real htmx
- Real htmx.min.js (v2.0.4, 50KB) replaces stub
- WebAuthn registration handlers (begin/finish) for adding security keys
- WebAuthn login handlers (begin/finish) for passwordless login
- Key management page (list/delete registered keys)
- Login page updated with "Login with Security Key" button + JS
- Session store for WebAuthn ceremonies (mutex-protected map)
- WebAuthn config passed from server command through to webserver
- Added LookupUserID helper for username-based WebAuthn login

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 21:33:45 -07:00
kyleandClaude Opus 4.6 49de9269d6 Rename service to EngPadSyncService (buf lint), add java_package, add buf.yaml
- Proto service renamed from EngPadSync to EngPadSyncService per buf
  STANDARD lint rule SERVICE_SUFFIX
- Added java_package and java_multiple_files options for Android client
- Added buf.yaml with STANDARD lint and FILE breaking detection
- Regenerated Go gRPC stubs, updated server references

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 21:25:09 -07:00
kyle 4dc71703fe Merge: structured logging (slog) 2026-03-24 20:54:55 -07:00
kyleandClaude Opus 4.6 a9e6ca022e Add structured logging with log/slog
Replace fmt.Printf logging calls with slog.Info/slog.Error for structured
JSON output to stderr. Add internal/log package to initialize the default
slog handler from the config log level. Fix .gitignore to only ignore the
binary at the repo root, not the cmd/eng-pad-server directory.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 20:52:22 -07:00
kyle 50ea97ec4b Merge: config validation + race testing (A-015, A-017) 2026-03-24 20:49:56 -07:00
kyleandClaude Opus 4.6 41839b7284 Add comprehensive config validation and race testing target
Split config validation into validateFields() (pure logic) and
validateFiles() (filesystem checks) for testability. New validations:
TLS file existence, token TTL parseability/positivity, Argon2 params > 0,
valid log level, non-empty listen addresses. Added 18 tests covering all
validation paths. Added `make test-race` target. Resolves A-015 and A-017.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 20:49:16 -07:00
kyleandClaude Opus 4.6 c5469c6bdf Document single-user model and MCIAS migration path in AUDIT.md
Single authenticated user by design. If multi-user is ever needed,
auth migrates to MCIAS — standalone auth won't be extended.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 20:23:57 -07:00
kyleandClaude Opus 4.6 ea9375b6ae Security hardening: fix critical, high, and medium issues from audit
CRITICAL:
- A-001: SQL injection in snapshot — escape single quotes in backup path
- A-002: Timing attack — always verify against dummy hash when user not
  found, preventing username enumeration
- A-003: Notebook ownership — all authenticated endpoints now verify
  user_id before loading notebook data
- A-004: Point data bounds — decodePoints returns error on misaligned
  data, >4MB payloads, and NaN/Inf values

HIGH:
- A-005: Error messages — generic errors in HTTP responses, no err.Error()
- A-006: Share link authz — RevokeShareLink verifies notebook ownership
- A-007: Scan errors — return 500 instead of silently continuing

MEDIUM:
- A-008: Web server TLS — optional TLS support (HTTPS when configured)
- A-009: Input validation — page_size, stroke count, point_data alignment
  checked in SyncNotebook RPC
- A-010: Graceful shutdown — 30s drain on SIGINT/SIGTERM, all servers
  shut down properly

Added AUDIT.md with all 17 findings, status, and rationale for
accepted risks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 20:16:26 -07:00
kyleandClaude Opus 4.6 51dd5a6ca3 Implement Phase 10: deployment (Dockerfile, systemd, install script)
- Multi-stage Dockerfile: golang:1.25-alpine builder, alpine:3.21 runtime
  CGO_ENABLED=0, stripped binary, non-root user
- systemd: service unit (hardened), backup oneshot, daily timer (02:00 UTC)
- Install script: create user, dirs, config, install units
- Updated PROGRESS.md with all completed phases

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 20:01:40 -07:00
kyleandClaude Opus 4.6 169063cd00 Implement Phase 9: FIDO2/U2F WebAuthn support
- WebAuthnUser implementing webauthn.User interface
- NewWebAuthn factory with configurable RP settings
- Credential storage: store, load, list, delete, update sign count
- User lookup by credential ID for login flow
- go-webauthn/webauthn library integrated

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 20:00:10 -07:00
kyleandClaude Opus 4.6 5c4575a67f Implement Phase 8: Web UI with htmx templates
- HTML templates: layout, login, notebook list, notebook view, page viewer
- Web server with chi router, embedded templates via //go:embed
- Login/logout flow with session cookies
- Notebook list, page grid with SVG thumbnails, page viewer
- Share link views (same templates, no auth chrome)
- Server command wired to start gRPC + REST + web servers concurrently
- Graceful shutdown on SIGINT/SIGTERM

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 19:59:07 -07:00
kyleandClaude Opus 4.6 fedb5e3301 Implement Phase 7: share link tests and expiry fix
- 4 tests: create/validate, expiry, revoke, list
- Fixed expiry check: negative durations now correctly expire links
  (was checking > 0 instead of != 0)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 19:57:03 -07:00
kyleandClaude Opus 4.6 37c2d35ceb Implement Phase 6: REST API with chi router
- Login endpoint (password → bearer token + session cookie)
- Auth middleware (bearer header or session cookie)
- Notebook list endpoint (authenticated)
- Page SVG/JPG rendering endpoints (authenticated)
- Notebook PDF download endpoint (authenticated)
- Share link endpoints: view, page SVG, page JPG, PDF (no auth)
- Route registration with chi groups

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 19:55:47 -07:00
kyleandClaude Opus 4.6 5993d20995 Implement Phase 5: SVG, JPG, PDF rendering
- SVG: strokes → SVG path elements with dashed/arrow support,
  coordinates scaled from 300 DPI to 72 DPI
- JPG: rasterization at 300 DPI using Go image package, Bresenham
  line drawing with round pen circles
- PDF: minimal PDF generation with raw operators, no external library
- 6 tests: SVG output, dashed style, arrow heads, JPG magic bytes,
  PDF header, page size calculations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 19:54:32 -07:00
kyleandClaude Opus 4.6 7d4e52ae92 Implement Phase 4: gRPC sync service
- Proto definitions (engpad.v1.EngPadSync) with 6 RPCs
- Generated Go gRPC code
- Auth interceptor: username/password from metadata
- SyncNotebook: upsert with full page/stroke replacement in a tx
- DeleteNotebook, ListNotebooks handlers
- Share link RPCs: CreateShareLink, RevokeShareLink, ListShareLinks
- Share link token management (32-byte random, optional expiry)
- gRPC server with TLS 1.3

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 19:52:47 -07:00
kyleandClaude Opus 4.6 846a6fe42d Implement Phase 3: CLI commands (init, server, snapshot, status)
- Cobra CLI with init (create DB + admin user), server (placeholder),
  snapshot (VACUUM INTO backup), status (health check + counts)
- All commands load config via --config flag
- init prompts for username and password (masked)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 19:50:02 -07:00
kyleandClaude Opus 4.6 286b886c06 Implement Phase 2: password auth (Argon2id + bearer tokens)
- Argon2id password hashing and verification with configurable params
- Bearer token generation (32-byte random), SHA-256 hashed storage,
  TTL-based expiry
- User creation and authentication helpers
- auth_tokens table added to migrations
- 6 tests: hash/verify, wrong password, create/auth user, token
  create/validate, token expiry

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 19:49:07 -07:00
kyleandClaude Opus 4.6 9077117e74 Implement Phase 0+1: project setup, config, database, migrations
- Go module, Makefile, .golangci.yaml, .gitignore, example config
- TOML config loading with validation
- SQLite database with WAL, foreign keys, busy timeout
- Schema migrations: users, webauthn_credentials, notebooks, pages,
  strokes, share_links with indexes and cascading deletes
- 4 tests: open+migrate, idempotent, foreign keys, cascade delete

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 19:47:38 -07:00
kyleandClaude Opus 4.6 0cce04b5b8 Initialize eng-pad-server with project documentation
- README.md: project overview, quick start, build commands
- CLAUDE.md: AI dev context, source tree, key conventions
- ARCHITECTURE.md: full system spec covering data model, auth
  (password + FIDO2/U2F), gRPC sync API, REST API, SVG/JPG/PDF
  rendering, web UI, configuration, deployment, security
- PROJECT_PLAN.md: 11 phases with discrete checkboxable steps
- PROGRESS.md: decision log and completion tracking

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 19:42:38 -07:00