Remove cans feature; harden pw_/tok_ cookie flags (pre-release fixes) #307

Merged
fen merged 2 commits from palette/t_1cedb8a0-remove-cans-feature-harden-cookie-flags into dev 2026-10-16 21:59:34 +00:00
Collaborator

Owner decision 2026-10-16: remove the half-integrated cans feature entirely (zero prod usage) and fix two related security nits from the audit.

Cans removal (feature gone, not stubbed):

  • Deleted internal/api/cans.go, templates/can.html, and all can routes: POST /api/pastes/can, GET/DELETE /api/cans/{id}, GET /api/cans/{id}/items/{item}, GET/POST /can/{id}
  • Removed is_can from /api/mine and /api/public; store layer simplified (no more paste_cans UNION in listings/counters); cans sweep rule dropped; 'can'/'cans' released from reserved slugs
  • Removed can CSS (.can-page/.can-item*), is_can badges in history.js/mine.js, dead helpers (expiryStringIfValid, templateEsc) and the #4-only web exports
  • Docs updated: docs/api.md cans section removed; README, LICENSE, docker-compose mentions cleaned
  • Tests: cans_test.go / cans_flow_test.go / cans_expiry_test.go / TestErrorCodeCanValidation removed; cookie_set_test now asserts Secure

Schema migration: paste_cans is dropped only when empty (non-empty table is kept and logged — dev has test cans to clean up first); pastes.can_id column dropped (prod verified clean 2026-10-16: 13 pastes, zero can_id set). New TestMigrateDropsCansSchema covers empty-table drop, non-empty keep, and fresh-DB cases.

Security hardening: pw_${id} (web.go unlock) and tok_${id} (server.go create + web.go re-set) cookies now carry Secure: true alongside HttpOnly + SameSite=Lax (all deployments HTTPS-only).

Verification: go vet ./... clean, go test ./... all pass, full-tree grep shows no can references outside the migration itself and the inert pre-implementation design sketches under sketches/.

Note: sketches/can-demo is a pre-implementation HTML mockup with no code paths; left untouched as design history.

Owner decision 2026-10-16: remove the half-integrated cans feature entirely (zero prod usage) and fix two related security nits from the audit. **Cans removal (feature gone, not stubbed):** - Deleted internal/api/cans.go, templates/can.html, and all can routes: POST /api/pastes/can, GET/DELETE /api/cans/{id}, GET /api/cans/{id}/items/{item}, GET/POST /can/{id} - Removed is_can from /api/mine and /api/public; store layer simplified (no more paste_cans UNION in listings/counters); cans sweep rule dropped; 'can'/'cans' released from reserved slugs - Removed can CSS (.can-page/.can-item*), is_can badges in history.js/mine.js, dead helpers (expiryStringIfValid, templateEsc) and the #4-only web exports - Docs updated: docs/api.md cans section removed; README, LICENSE, docker-compose mentions cleaned - Tests: cans_test.go / cans_flow_test.go / cans_expiry_test.go / TestErrorCodeCanValidation removed; cookie_set_test now asserts Secure **Schema migration:** paste_cans is dropped only when empty (non-empty table is kept and logged — dev has test cans to clean up first); pastes.can_id column dropped (prod verified clean 2026-10-16: 13 pastes, zero can_id set). New TestMigrateDropsCansSchema covers empty-table drop, non-empty keep, and fresh-DB cases. **Security hardening:** pw_${id} (web.go unlock) and tok_${id} (server.go create + web.go re-set) cookies now carry Secure: true alongside HttpOnly + SameSite=Lax (all deployments HTTPS-only). **Verification:** go vet ./... clean, go test ./... all pass, full-tree grep shows no can references outside the migration itself and the inert pre-implementation design sketches under sketches/. Note: sketches/can-demo is a pre-implementation HTML mockup with no code paths; left untouched as design history.
fen added 1 commit 2026-10-16 21:50:47 +00:00
Remove cans feature; add Secure flag to pw_/tok_ cookies
CI / docker (pull_request) Skipped
CI / test (pull_request) Successful in 21s
e54fbc36ef
Owner decision 2026-10-16: the cans feature (bundles of pastes, #4) was
half-integrated and has zero prod usage; removing it eliminates four audit
findings by deletion.

Removed:
- internal/api/cans.go and all can routes (/api/pastes/can, /api/cans/*,
  /can/{id}) plus handleCanPage/renderCan
- is_can from /api/mine and /api/public responses
- store layer: CanRow, can store funcs, paste_cans UNION in listings,
  cans sweep; reserved slugs 'can'/'cans' released
- templates/can.html, can CSS, is_can badges in history.js/mine.js
- cans tests (cans_test.go, cans_flow_test.go, cans_expiry_test.go,
  TestErrorCodeCanValidation)
- docs/api.md cans section, README/LICENSE/docker-compose mentions

Store migration: drops paste_cans only when empty (non-empty table is
kept and logged; prod verified clean 2026-10-16) and drops the dormant
pastes.can_id column. Covered by new TestMigrateDropsCansSchema.

Security hardening (audit findings): pw_<id> (unlock) and tok_<id>
(deletion-token) cookies now carry Secure: true in addition to
HttpOnly + SameSite=Lax; all deployments are HTTPS-only. cookie_set_test
now asserts Secure.

go vet ./... and go test ./... pass.
fen added 1 commit 2026-10-16 21:57:25 +00:00
docs: remove leftover "Create a can" curl example for deleted endpoint
CI / docker (pull_request) Skipped
CI / test (pull_request) Successful in 20s
1e696b1cbb
fen merged commit c02550050f into dev 2026-10-16 21:59:34 +00:00
Sign in to join this conversation.