Cybersecurity-Projects/PROJECTS/beginner/canary-token-generator/backend/internal
CarterPerez-dev 593433fc03 feat(canary): manage page handlers + DTOs (GET + DELETE /m/{manage_id})
Adds the HTTP layer for spec §8.4. The UUID in the URL is the
capability — no other auth required, by design.

- token/dto.go: ManageTokenView (slimmer than Response — no manage_id,
  no manage_url, no metadata, since the user is already on the manage
  page and those would be redundant), ManagePage{NextCursor, HasMore},
  ManageResponse{Token, Events, EventsTotal, EventsSilencedActive, Page}.
  Token.ToManageView(triggerURL) builder. Events use the existing
  event.Response (already matches spec shape exactly).
- token/handler.go: EventQuery + DedupCounter interfaces declared near
  the existing EventRecorder + FingerprintRecorder; same dependency-
  injection style. NewHandler signature gains the two new args (5 → 6;
  test sites + main.go updated).
- GetManage(w, r): parses ?cursor= (int64, must be >= 0) and ?limit=
  (defaults 20, capped at 100). Returns 404 envelope for unknown
  manage_id (envelope, not bare http.NotFound, so frontend gets a
  parseable error code). 400 BAD_CURSOR for non-numeric or negative.
  Calls svc.GetByManageID + eventQuery.ListByToken + CountByToken +
  dedupCounter.CountActiveDedup; assembles the manage payload.
- DeleteManage(w, r): 204 on success, 404 on miss. Cascade-delete is
  via the existing tokens-events FK ON DELETE CASCADE.
- buildPage helper: NextCursor is the string of the last event's ID
  iff len(events) == limit (matches spec example "next_cursor": "41").

Tests cover happy path, 404 on unknown id, 400 on bad/negative cursor,
?limit= respected, ?limit=999 capped at 100, DELETE happy + 404.
2026-05-14 01:07:09 -04:00
..
admin fix(canary-phase0): address audit findings before phase rollup 2026-05-10 05:37:32 -04:00
config feat(canary): wire event + notify into runtime + create-tier rate limits 2026-05-14 00:31:24 -04:00
core fix(canary): replace //nolint pragmas with explicit error handling 2026-05-13 13:28:44 -04:00
event feat(canary): event.CountActiveDedup + token.DeleteByManageID for manage page 2026-05-14 01:06:45 -04:00
health fix(canary): replace //nolint pragmas with explicit error handling 2026-05-13 13:28:44 -04:00
middleware feat(canary): turnstile verifier + middleware 2026-05-13 15:08:37 -04:00
notify fix(canary-phase10): escape geo wrapping parens for MarkdownV2 before rollup 2026-05-14 00:47:08 -04:00
server fix(canary-phase1): clear all post-phase-1 audit observations + header normalization 2026-05-10 06:15:26 -04:00
testutil fix(canary): clear pre-audit lint debt + migrate golangci config to v2 2026-05-12 02:49:56 -04:00
token feat(canary): manage page handlers + DTOs (GET + DELETE /m/{manage_id}) 2026-05-14 01:07:09 -04:00
turnstile feat(canary): turnstile verifier + middleware 2026-05-13 15:08:37 -04:00